Host multiple website on Apache Web Server!

feather-small When now days its getting economical to have a server, the need of hosting many website on single server is in demand.  This article will cover how to host multiple instance of website on a Apache web server.

To start with make sure you have apache2 package installed on your server.

To install apache2 on Ubuntu/debian/Mint server pass following command

# apt-get install apache2

To install it on Fedora/Redhar/Suse

# yum install apache2

After installing Apache package, create directory for your website. To create directory pass the following command.

# mkdir -p /path/to/directory/of/virtual/website

Now make sure you allow apache user to be owner of that directory so that site can work flawlessly(This method is important if you have wordpress installation in my case 😉 )

# chown -R www-data:www-data /path/to/directory/of/virtual/website

www-data is default user in many distros.

To make sure other user can access the directory and files pass following command 

# chmod -R 755 /path/to/directory/of/virtual/website

Now create a index.html file with your content in that directory.

After finishing above steps, we can now proceed with creating the Virtual Host for Apache 🙂

To start with it, you have to create new host file in Apache configuration directory

# cp /etc/apache2/sites-available/default /etc/apache2/sites-avaialble/

Edit that virtual host file and add following line after <VirtualHost *:80>


Make sure you replace with your website address 😉

In case you want that site to be available with more then one name you can include following (Eg. add following after ServerName line


Next step is to point the file to correct directory

Replace all instance of /var/www or /var/www/html/ with /path/to/directory/of/virtual/website

Now your file should be look something

<VirtualHost *:80> 
	DocumentRoot /path/to/directory/of/virtual/website
	<Directory /> 
		Options FollowSymLinks 
		AllowOverride None 
	<Directory /path/to/directory/of/virtual/website> 
		Options Indexes FollowSymLinks MultiViews 
		AllowOverride None 
		Order allow,deny 
		allow from all 
	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
	<Directory "/usr/lib/cgi-bin"> 
		AllowOverride None 
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
		Order allow,deny 
		Allow from all 
	ErrorLog ${APACHE_LOG_DIR}/error.log 
	# Possible values include: debug, info, notice, warn, error, crit, 
	# alert, emerg. 
	LogLevel warn 
	CustomLog ${APACHE_LOG_DIR}/access.log combined 
like this

Save the file, and activate the virtual host by following command :

# a2ensite

After avtivating virtual host, restart or reload the Apache service by passing following command

# service apache2 reload
# service apache2 restart

Repeat the step after installing apache2 for adding more virtual host.


P.S. Apache and the Apache feather logo are trademarks of The Apache Software Foundation.

By | 2018-04-09T06:34:13-04:00 April 21st, 2013|Editorial, Featured Post, Tips, Tutorials|Comments Off on Host multiple website on Apache Web Server!

About the Author: