How To Set Up Apache Virtual Hosts on Ubuntu

Published: 26 February 2024
on channel: Mehul Chaudhari
35
2

This tutorial will guide you through setting up multiple domains and websites using Apache virtual hosts on an Ubuntu 20.04 server. Set up Apache virtual Hosts on the Ubuntu Operating System.

Go to the project directory if you have an existing project or make a new project directory if you start from scratch
Below is the project directory path
/var/www/html/my-project
In this project directory path, We are creating one new index file. Also, We are writing some HTML code and PHP echo statements to display the output in the browser.
Now we are moving to create a virtual host file.

Virtual file is your actual configuration of your host and project directory how the Apache server will respond
The Apache already provide one default host file, the name is 000-default.conf and below is the path of this file.
/etc/apache2/sites-available/000-default.conf
Copy the default host config file and create a new file according to your project name.
/etc/apache2/sites-available/my-project.conf
Set the ServerName and ServerAlias and project directory path as we saw the beginning of our video
Enable the our host config file using this command sudo a2ensite my-project.conf
And then restart the our Apache server sudo systemctl restart apache2
Add domain in hosts file for pointing. 127.0.0.1 my-project.local
Finally, run in the browser my-project.local


Watch video How To Set Up Apache Virtual Hosts on Ubuntu online, duration hours minute second in high quality that is uploaded to the channel Mehul Chaudhari 26 February 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 35 times and liked it 2 visitors.