To install and configure Apache Virtual Host on AlmaLinux 9, follow the steps below.
Step 1 : Start by updating your system packages to ensure all the software is up to date.
Step 2 : If Apache is not already installed, you can install it using the following command:
Step 3 : Next, create a directory to store your website files. For example, let's create a directory for your domain example.com
:
Step 4 : Now, create a simple index.html
file to display on your website:
Step 5 : Ensure the Apache user has the appropriate permissions to access the website directory:
Step 6 : Create a new configuration file for your virtual host. For example, example.com.conf
:
Add the following content to define your virtual host:
Save and close the file.
Step 7 : Before restarting Apache, it's important to test the configuration for errors:
If the test is successful, restart Apache to apply the changes:
Step 8 : Open a web browser and go to http://example.com
. If everything is set up correctly, you should see the "Welcome to example.com" page.
Congratulations, you have successfully set up Apache Virtual Host on AlmaLinux 9!