Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Hosting multiple web sites on a single server |
|
Author |
|
BDragojlovic
Joined: 11 Nov 2005 Posts: 1
|
Posted: Fri 11 Nov '05 20:54 Post subject: Hosting multiple web sites on a single server |
|
|
How can I host multiple websites (each one with a dedicated IP address) on a single server?
Can it be done via a single installation of Apache (and the proper configuration file), or do I need to install Apache once for each website.
I want each site to be a "root" side (and NOT a folder off of the roo).
e.g.
siteA.com
siteB.com
and NOT
thesite.com/siteA
thesite.com/siteB
Thanks, |
|
Back to top |
|
Xing Moderator
Joined: 26 Oct 2005 Posts: 49
|
|
Back to top |
|
Brian
Joined: 21 Oct 2005 Posts: 209 Location: Puyallup, WA USA
|
Posted: Sun 13 Nov '05 8:14 Post subject: |
|
|
Hi BDragojlovic,
I have about 500 vhosts in multiple include files that are loaded into the primary httpd.conf file. It is easy for me to keep my house clean by organizing these VHOSTS onto seperate include files but if you are just starting out and you have maybe a handful of domains / sub-domains, then you can do it all within the httpd.conf file with out it getting too long to manage.
Here is an example part of one of my vhost entry files:
Code: |
<VirtualHost *>
ServerName www.domain.com
ServerAlias domain.com www.domain2.com www.domain3.com
DocumentRoot x:/www/dir1/dir2/
php_admin_value disable_functions "shell_exec,passthru,proc_close,proc_get_status,proc_open,proc_terminate,system"
php_admin_value max_execution_time "120"
php_admin_value memory_limit "16M"
php_admin_value session.use_only_cookies "0"
php_admin_value magic_quotes_gpc "Off"
php_admin_value session.auto_start "1"
php_admin_value session.cookie_lifetime "0"
php_admin_value session.cache_expire "320"
</VirtualHost>
<VirtualHost *>
ServerName sub.domain.com
DocumentRoot x:/www/sub_domain/
php_admin_value disable_functions "shell_exec,exec,virtual,passthru,proc_close,proc_get_status,proc_open,proc_terminate,system"
php_admin_value max_execution_time "30"
php_admin_value memory_limit "8M"
php_admin_value post_max_size "2M"
php_admin_value upload_tmp_dir "x:/www/sub_domain/tmp/"
</VirtualHost>
<VirtualHost *>
ServerName sub2.domain.com
DocumentRoot x:/www/sub2_domain/dir/
php_admin_value disable_functions "shell_exec,exec,virtual,passthru,proc_close,proc_get_status,proc_open,proc_terminate,system"
php_admin_value max_execution_time "60"
php_admin_value memory_limit "2M"
php_admin_value post_max_size "1M"
</VirtualHost>
<VirtualHost *>
ServerName www.domain4.com
ServerAlias domain4.com *.domain4.com domain4.domain.com
DocumentRoot x:/www/domain4/
php_admin_value disable_functions "shell_exec,exec,virtual,passthru,proc_close,proc_get_status,proc_open,proc_terminate,system"
php_admin_value open_basedir "x:/www/domain4/"
php_admin_value upload_tmp_dir "x:/www/domain4/tmp/"
php_admin_value session.use_only_cookies "1"
</VirtualHost> |
In my httpd.conf file I have the follwing:
Code: | ###### get vhosts ######
NameVirtualHost *
Include conf/domain_list_1.conf
Include conf/domain_list_2.conf
Include conf/domain_list_3.conf
Include conf/domain_list_4.conf
###################### | This bit "includes" the domain info so that I don't have a massive 4000 line httpd.conf file.
= = = = = = = = = = = = = = = = = = = =
For you though, it does NOT matter where the ROOT directory for the server is, when you set up your vhosts. So, try something like this:
Code: | NameVirtualHost *
<VirtualHost *>
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
DocumentRoot x:/www/domain1/
</VirtualHost>
<VirtualHost *>
ServerName www.domain2.com
ServerAlias domain2.com *domain2.com
DocumentRoot x:/www/domain2/
</VirtualHost> |
I posted all that code so that you could see how the set could look strikingly different, but in the last code example I simply posted a very straightforward illustration of how to place two vhosts on a drive, any drive, regardless of where the server's root directory is.
If possible, place your vhosts on a separate hard drive, that I my preference anyway. I like to keep all vhosts on a drive that does not also contain any root folders / scripts, no MySQL, no Perl or PHP engine, essentially, just on data drives.
Are you running any scripting languages as well?
Good luck, hope this has helped a bit.
--
Brian |
|
Back to top |
|
sniper_wolf48
Joined: 11 Jan 2007 Posts: 1
|
Posted: Thu 11 Jan '07 1:29 Post subject: Multiple Websites on one server |
|
|
Hello, I tried the code listed above in my config and it still redirects me to my primary website, I am trying to host my game site http://tod.servegame.com and another seperate domain via www.map.com just an e.g.
but within my same IP as i only have one internet connection, how would i customize that code to do it? |
|
Back to top |
|
strigoi
Joined: 15 Dec 2005 Posts: 36
|
Posted: Wed 17 Jan '07 11:12 Post subject: this will do |
|
|
NameVirtualHost *
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *>
ServerName yoursite.com
ServerAlias www.yoursite.com
DocumentRoot "c:/program files/apache group/apache2/htdocs/site1/"
</VirtualHost>
<VirtualHost *>
ServerName yoursite2.com
ServerAlias www.yoursite2.com
DocumentRoot "c:/program files/apache group/apache2/htdocs/site2/"
</VirtualHost>
Change ServerName
Change ServerAlais
Change DocumentRoot |
|
Back to top |
|
|
|
|
|
|