How to set up Apache Virtual Host on Ubuntu 24.10

To set up and configure an Apache Virtual Host on Ubuntu 24.10, follow these steps.

Step 1 : Begin by updating the package list to ensure all repositories are current:

Step 2 : If Apache2 is not already installed, install it using:

Confirm the installation by checking the Apache version:

Step 3 : Create a dedicated directory for your website's files. Replace example.com with your domain name:

Step 4 : Add a simple HTML file as a placeholder for your website:

Step 5 : Ensure the Apache user has the necessary permissions to access your website files:

Step 6 : Create a new configuration file for your domain:

Add the following content, replacing example.com with your domain name:

Save and close the file.

Step 7 : Enable your new virtual host configuration:

Step 8 : Check your Apache configuration for errors:

If there are no errors, restart Apache:

Step 9 : Visit your domain (e.g., http://example.com) in a browser. You should see the placeholder index.html page with the message "Welcome to example.com"

Congratulations! You have successfully set up an Apache Virtual Host on Ubuntu 24.10.