In this article we will teach the reader how to use a singe dedicated server, to serve as many websites as you want, from a single dedicated server.
I remember when I had all my client's websites setup on different shared hosting accounts, from different providers etc, its a real pain to maintain..
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
setup apache to serve multiple sites from a single dedicated server
1. puf f ingde v.co m
http://puffingdev.co m/setup-apache-to -serve-multiple-sites-fro m-a-single-dedicated-server/
Setup apache to serve multiple sites from a single dedicated
server
— December 24, 2013
In this article we will teach the reader how to use a singe
dedicated server, to serve as many websites as you want,
f rom a single dedicated server.
I remember when I had all my client's websites setup on
dif f erent shared hosting accounts, f rom dif f erent providers
etc, its a real pain to maintain..
Serving several sites f rom a single Ubuntu server is done by
using "vhosts", these can be name-based so you can serve
both www.f irstwebsite.com and www.secondwebsite.com f rom
the same server, but they can also be IP-based.
Each vhost has a number of conf ig f iles, and a webroot where the actual f iles reside, by def ault Ubuntu will
only have the def ault vhost setup, wich has its webroot at /var/www
In this example we will create 2 new vhosts f or the 2 examples above, and then we will disable the def ault
webroot, so the f irst thing we will do is create 2 new f olders, wich will serve as the webroot f olders f or the
2 domains
1. sudo mkdir /var/www/first websit e.com
2. sudo mkdir /var/www/secondwebsit e.com
Now we will use the conf ig f ile f rom the def ault vhost, as a starting point to create our conf ig f iles f or our
2 new vhosts
1. sudo cp /et c/apache2/sit es-available/default /et c/apache2/sit es-available/first websit e.com
2. sudo cp /et c/apache2/sit es-available/default
/et c/apache2/sit es-available/secondwebsit e.com
Now we have to edit BOT H these new conf ig f iles, as shown below, insert the "ServerName", and change
the "DocumentRoot" and "Directory" to point to your new webroot f olders
2. 1. <Virt ualHost *:80>
2. ServerAdmin webmast er@first websit e.com
3. ServerName first websit e.com
4. Document Root /var/www/first websit e.com
5. <Direct ory />
6.
Opt ions FollowSymLinks
7.
AllowOverride All
8. </Direct ory>
9. <Direct ory /var/www/first websit e.com/>
10.
Opt ions -Indexes FollowSymLinks Mult iViews
11.
AllowOverride All
12.
Order allow,deny
13.
allow from all
14. </Direct ory>
15. ErrorLog ${APACHE_LOG_DIR}/error.log
16. # Possible values include: debug, info, not ice, warn, error, crit ,
17. # alert , emerg.
18. LogLevel warn
19. Cust omLog ${APACHE_LOG_DIR}/access.log combined
20. </Virt ualHost >
Now that we have our conf ig f iles setup, and our webroot f olders setup, we are ready to enable our new
vhosts, and disable our def aut one, do this by using the f ollowing commands:
1. sudo a2ensit e first websit e.com
2. sudo a2ensit e secondwebsit e.com
3. sudo a2dissit e default
Just one more thing lef t, we have to reset our Apache server so that it will reload its conf ig f iles.
1. sudo service apache2 reload
T hats it, you have now successf ully setup you Ubuntu server to serve several sites f rom a single server.
However, if you are f ollowing this tutorial, and are having trouble, f eel f ree to drop a comment here
Copyright 2013 - Puf f ingDev.com. All Rights Reserved.