View Full Version : Hosting Multiple Sites on Apache
Rollo Tamasi
October 30th, 2005, 03:26 PM
Hi Guys,
How do you setup Ubuntu/Apache so that you can host multiple websites on your box. I have a 60Gig Harddrive, and i would like to setup my box so that i can host 10 sites with 6Gig partitions each. I would like to have SQL running on each of those partitions as well, i'm guessing i would have to congfigure sql as well to work on each partition?
(I have a static IP, btw)
JLTB
October 30th, 2005, 05:47 PM
Hey Rollo,
The easiest way to do this (and the most widely accepted) is to use virtual hosts in apache. Basically apache will start up a seperate sub-instance of itself for each of your virtual hosts so they are essentially completely seperated from eachother.
I would suggest installing webmin or some other GUI tool to configure it up. You can also do some searching on "apache virtual hosts" to find more info on the matter.
For your database I would set up 1 database server with 6 databases inside with 6 users who have permissions on only their own database. This should be enough to get 6 sites going; however, if you want more of an ISP approach whereby each site can have multiple DB's etc... You'll need to get into "chrooting" and other more compliated stuff.
That should be enough to get you started. For a basic setup, webmin and phpmyadmin should be enough to get it all config'ed up.
Cheers!
Rollo Tamasi
November 4th, 2005, 12:54 AM
Thanks for your response, is this the best approach to take as recommended by JLTB?
When you say you would setup a database server, do you mean a dedicated box which just hosts db's connected to my LAN?
Hey Rollo,
For your database I would set up 1 database server with 6 databases inside with 6 users who have permissions on only their own database. This should be enough to get 6 sites going; however, if you want more of an ISP approach whereby each site can have multiple DB's etc... You'll need to get into "chrooting" and other more compliated stuff.
JTorres176
November 4th, 2005, 03:20 AM
running six different sql servers on one machine could cause some serious performance and memory (or lack of memory actually) problems. if you're using PostgreSQL, install it once, then go through the commands for adding users and databases
sudo su - pgsql
createuser dbuser1
createdb -O dbuser1 db1
createuser dbuser2
createdb -O dbuser2 db2
(and so on)
You can run multiple databases in one installation, which will run completely different databases determined by user and database names... access them by running
psql -U dbuser1 <-- accesses db1
psql -U dbuser2 <-- accesses db2
(and so on)
I'm sure MySQL has a similar process, but I'm unfamiliar with it. :)
pmt
November 5th, 2005, 05:08 PM
Put a textfile into the directory /etc/apache2/conf.d/
Name it virtual_host (for example)
Write the following configuration directives in this file
# Virtual host configuration
NameVirtualHost *
<VirtualHost *>
DocumentRoot /var/www/domain1
ServerName domain1
<Directory /var/www/domain1>
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/domain2
ServerName domain2
<Directory /var/www/domain2>
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
# and so on ...
restart apache2
> sudo /etc/init.d/apache2 restart
thats all.
LordHunter317
November 6th, 2005, 01:15 PM
No!
First off, 'NameVirtualHost' is already in sites-available/000-default, and should not be repeated anywhere else.
Second, you don't put virtual host definitions there. That directory is reserved for configuration files installed by packages.
You place virtual host directives in one file per site, in sites-available. You then symlink them to sites-enabled, perhaps changing the name so they're in the proper loading order.
obscenic
November 7th, 2005, 08:37 PM
Why do you symlink the files, rather than just creating them in sites-enabled?
LordHunter317
November 8th, 2005, 01:03 AM
Mainly so you can enable/disable them as needed.
obscenic
November 8th, 2005, 01:45 PM
Ah, case in point! Thanks for all the tips. (working on similar problems)
Would I be hijacking if I asked what a proper setup for an individual virtual host file should be?
Nevermind! Got it solved! Now to tackle the downloading phtml instead of processing as php issue... grr
Also solved!
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.