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, http://www.hello.com:

vim hello.com

Add this content to the hello.com file

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

you can also customize to make the log inside webroot

Activate the site by issuing the following command

sudo a2ensite  hello.com

Now reload Apache

sudo /etc/init.d/apache2 restart

or

sudo service apache2 restart

And youre done 🙂

Happy Hacking

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s