Setup Virtual Hosts in Ubuntu
Open terminal then run the command.
cd /etc/apache2/sites-available/
sudo cp default llanalewis.dev
sudo nano llanalewis.dev
Change llanalewis.dev to your vhost name. In some ubuntu versions, default is 000-default
Copy and paste the code below to llanalewis.dev:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName llanalewis.dev
DocumentRoot /home/user/public_html/llanalewis_dev
<Directory /home/user/public_html/llanalewis_dev>
AllowOverride All
allow from all
</Directory>
</VirtualHost>
Save and close the file then open /etc/hosts. Add the line below to the list of your hosts
127.0.0.1 llanalewis.dev
Save and close /etc/hosts then on the terminal enable your new vhost by running the command below:
sudo a2ensite llanalewis
To disable the site, just run:
sudo a2dissite llanalewis
To apply the changes, restart your apache, type on the terminal:
sudo service apache2 restart
On your favorite browser, type your new virtual host name http://llanalewis.dev/
Comments
Post a Comment