View Full Version : Best Practice for Multiple Domains under one VPS

12-09-2003, 09:28 PM
Does anyone have any suggestions/best practice on how to structure adding multiple domains to one VSP.

We want to have Domain1, Domain2, & Domain3, but keep all their HTdocs separate.

I was just thinking of setting up each domain to point like this


are their any issues with this kind of setup?

I know I have plenty of VPS' but we are going to structure a few VPS based on who manages them. Since we manage about 4 domains our self, it makes sense to put all those under one VSP, that way we have additional VPS to resell to other people.

12-10-2003, 01:22 AM
If all the domains are under the same management (i.e. they can share the same Site Manager and you have control of the users names) there should not be a problem.
You have a little more work if they need separate cgi-bin directories but its not an issue.

<-- R O B -->
12-10-2003, 09:31 AM
I've been struggling through with this set up, jalal - do you know how to set up the httpd.conf file to allow cgi-bins for each virtualhost?

Other issues I've come accross are:

ASP: Will work for the main domain but not for any virtual host under this doamin - i've got a support ticket with westhost at the moment but they seem unsure how to set this up :(

DSN's again these seem to be ignored when I set them up in the odbc cfg file.

site alias's - the control panel doesn;t let you state which urls should resolve to the same virtual host - you have to enter each url as a seperate host (or alter the httpd.conf file) .

logging - you can't specify from the manager where individual virtual hosts should log their files.

Has anyone got a good resource for managing the VPS, as the set up seems rather different to normal apache config.

12-10-2003, 11:34 AM
ASP: dunno anything about this.

Site Manager doesn't seem to really handle much in the way of working with multiple domains, you'll probably have to do it through SSH.

In the virtual servers section, you'll need to set the ErrorLog and CustomLog to get the separate log files.

12-11-2003, 04:36 AM
Dear ROB, I'm sort of past that stage you were in. Thanks to all the kind souls here, Shawn, Fayez and Jalal.

In return here's my tutorial, I'm not that tidy or that descriptive but hope these helps.

Requirements needed by you can edited in httpd.conf file -as earlier said.

Looking from what I've posted as below, I think that's what you basically requested in your post ?

Note the cgi-bin - basically is just creatin a script alias - u can have as many script alias as possible.

Logs - name after the particular domain - you can have it all in the log folder for easier managment.
All these can be done via ssh or downloading the httpd.conf via ftp.
But I'm beggining to love the power of ssh :)
After all these remember to restart your vps.
IP based vps are more responsive I feel.

In your virtual host settings:usually

&lt;/VirtualHost *>
ScriptAlias /cgi-bin/neomail /var/www/cgi-bin/neomail
Alias /neomail /var/www/html/neomail
ScriptAlias /cgi-bin/ /www/htdocs/abc/cgi-bin/
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /www/htdocs/abc
CustomLog logs/abc.log combined
ErrorLog logs/abc-error.log

The harder part will be the sendmail.cf for multiple emails. That I'm still reading :)

12-11-2003, 09:17 AM
Good info firebirdfan! Do you mind if I duplicate it on my board? If I follow you right this is all done by editing the httpd.conf file that can be found in /ect/httpd/conf directory and then restarting the VPS via the Site Manager or typing restart in SSH. Is that correct?

12-11-2003, 12:25 PM
The first line of the virtual host should be:

&lt;VirtualHost *>

12-11-2003, 06:47 PM
Shawn that info can be easily gotten anywhere & just a little editing here & there will do the trick - so do freely post it on your board.

And Jalal thanks for the pointer if not anybody copying directly would definitely have their virtual host not working :)

So the correct one would be
&lt;VirtualHost *>
ScriptAlias /cgi-bin/ /www/htdocs/abc/cgi-bin/
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /www/htdocs/abc
CustomLog logs/abc.log combined
ErrorLog logs/abc-error.log

After creatin the script alias to the particular path in your site you must create the folder cgi-bin exactly & place your perl scripts there and see if it works.
You can set your document root whereever you want - just make sure your path & slashes are right. :)

After having the logs named you are advised to edit the logrotate.conf. If not the newly named logs will not rotate & your virtual host log file will grow & grow & slow down apache :)

The logrotate.conf I'll post later.

Yes httpd.conf is located there as mentioned by Shawn.

You can use ssh to do this

just pull out your putty.

to go to httpd.conf to edit

type cd /etc/httpd/conf
type pico httpd.conf
to go directly to virtualhost config
press CTRL + W - it will then prompt you what word you want to match.

After that edit your virtual host config

After finishing all these. press CTRL + X
It will prompt you wheter you want to save or not - type Y
then Enter
after that type restart .
If you are on an IP based VPS it will come out OK, OK & OK if you have mysql installed.
If name based it will come out rc.d twice. - but it's ok

So that's that, giving back to the community.

<-- R O B -->
12-12-2003, 04:11 AM
thanks ! :D

One other thing you might want to consider adding is :

ServerAlias abc.com *.abc.com

This will resolve anythingyoulikehere.abc.com to your site........ now if only I can figure out myodbc dsns............... :shock:

<-- R O B -->
01-09-2004, 05:27 AM
ok for those of you wanting to add asp to the virtual host you need to the following (where abc.com is your domain name and abc is the root folder for the virtual host):

cd /usr/local/casp
ln ../apache/htdocs/abc abc.com-asp s
cd /www/htdocs/abc
type ln /usr/local/casp/abc.com-asp abc.com-asp s

you also need to change the document root to :

DocumentRoot /usr/local/casp/abc.com-asp

Edit httpd.conf so that the virtual host requiring asp has these lines added:

RewriteCond %{REQUEST_URI} !^/abc.com-asp.*$
RewriteRule ^(.*)\.as(p|a) /abc.com-asp/$0 [R]
RewriteEngine on

Finally you need to log a support call with westhost to get them to change some settings on the main server