How to setup Apache Virtualhost

The term Virtual Host refers to the practice of maintaining more than one web site on one Apache machine or server.

Go to your apache configuration files:

cd /etc/apache2/sites-available

Create a configuration file for your new site. For an example site,


Add this content to the file

<VirtualHost *:80>
ServerAdmin me@myserver
DocumentRoot /var/www/hello_webroot/
ServerAlias *
CustomLog /var/log/apache2/ combined

you can also customize to make the log inside webroot

Activate the site by issuing the following command

sudo a2ensite

Now reload Apache

sudo /etc/init.d/apache2 restart


sudo service apache2 restart

And youre done 🙂

Happy Hacking


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s