Virtual Host Setup On Ubuntu By Gagan
Create Virtual Host On Ubuntu Machine
13/01/23 1
Step 1
Enable virtual hosts by editing httpd.conf, if it is not enabled
already. Once you enable it you can skip this step next time
sudo gedit /opt/lampp/etc/httpd.conf
Find #Include etc/extra/httpd-vhosts.conf and remove the # to un-
comment this line
Include etc/extra/httpd-vhosts.conf
13/01/23 2
Step 2
Add new virtual host by opening the httpd-vhosts.conf file
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Usually, by default there are two virtual hosts in this file. You can edit
one or create new one by copy-pasting one of them. The required
entries are DocumentRoot and ServerName
ServerAdmin your_email@domain_name.com
DocumentRoot /opt/lampp/htdocs/mysite_folder
ServerName mysite.local
ServerAlias www.mysite.local
13/01/23 3
Step 3
Next, you will need to tell Xampp server where to find the address
you added above:
sudo gedit /etc/hosts
Add the following line:
127.0.0.1 mysite.local
13/01/23 4
Step 4
Restart xampp server by doing
sudo /opt/lampp/lampp restart
Type http://local.mysite in browser’s address bar and it should
work
13/01/23 5
Comments