Saturday, November 05, 2011

Name Virtual Host

Edit httpd.conf

sudo vi /etc/apache2/httpd.conf
Add this line

NameVirtualHost *:80
NOTE: You can replace *:80 with your_ip_address:80

Now create the domain name config file. I use the

sudo vi /etc/apache2/sites-available/
Add this to the file

DocumentRoot /var/www/
ErrorLog /var/www/
CustomLog /var/www/ combined

Make sure the directories in the config exists

NOTE: use the mkdir command like this if needed

sudo mkdir /var/www/
sudo mkdir /var/www/
Now we need to enable the new config file like this

sudo a2ensite
You should see a notice to restart apache, use this command

/etc/init.d/apache2 restart
Now we need a test file to view

sudo vi /var/www/
Add some text

Open your web browser and go to your new domain

No comments: