LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-24-2006, 05:10 PM   #1
Wack47
LQ Newbie
 
Registered: Sep 2005
Location: MO
Posts: 7

Rep: Reputation: 0
Running multiple subdomians on Apache 2.0 as vhosts


A couple of weeks ago my boss asked me to see if we couldnt get subdomains running on our webserver. He basically is wanting about 50 subdomains for one domain (1.my.com, 2.mydomain.com, etc) and each subdomain would have its own webpage. I have been researching on and off since that time, and am perplexed on how to do this to say the least. On our webserver websites (differnt domain names) using vhosts.

Here is my httpd2.conf configuration...

### Main Configuration Section
### You really shouldn't change these settings unless you're a guru
###
ServerRoot /etc/httpd/2.0
#ServerName localhost
#LockFile /etc/httpd/httpd.lock
PidFile /var/run/httpd.pid
ErrorLog logs/error_log
LogLevel warn
DocumentRoot /var/www/html



### Dynamic Shared Object (DSO) Support
###
### You should always leave those three, as they are needed for
### normal use.
### mod_access (Order, Allow, etc..)
### mod_log_config (Transferlog, etc..)
### mod_mime (AddType, etc...)

LoadModule access_module modules/mod_access.so
LoadModule auth_module modules/mod_auth.so
LoadModule auth_anon_module modules/mod_auth_anon.so
##LoadModule auth_dbm_module modules/mod_auth_dbm.so
LoadModule auth_digest_module modules/mod_auth_digest.so
##LoadModule charset_lite_module modules/mod_charset_lite.so
##LoadModule case_filter_module modules/mod_case_filter.so
##LoadModule case_filter_in_module modules/mod_case_filter_in.so
##LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
##LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
##LoadModule mime_magic_module modules/mod_mime_magic.so
##LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
##LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule asis_module modules/mod_asis.so
LoadModule info_module modules/mod_info.so
LoadModule cgi_module modules/mod_cgi.so
##LoadModule cgid_module modules/mod_cgid.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule imap_module modules/mod_imap.so
LoadModule actions_module modules/mod_actions.so
##LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

###
### Global Configuration
###
# We now support multiple apache configurations on the same server. In
# common.conf, we put all directives that are common to all implementations
# (httpd, httpd-perl, etc.)
# For Apache2 we load all conf files in conf.d
Include /etc/httpd/conf.d/*.conf
Include conf/commonhttpd.conf


###
### IP Address/Port and Proxied configuration section
###
# The APACHEPROXIED setting can be set in /etc/rc.d/init.d/httpd if you
# are using a proxy or accelerator, like the Apache-SGI or khttpd, so that
# the fast web server serves static content while Apache handles the
# cgi or php files

#BindAddress *
<IfDefine APACHEPROXIED>
Listen 8080
</IfDefine>
<IfDefine !APACHEPROXIED>
Listen 80
</IfDefine>

# Likewise, we can set apache as the server by default and send perl
# requests via ProxyPass to apache-mod_perl. It increases performance
# since the perl interpreter is only used for perl and the standard apache
# does all the html and image files, with a smaller footprint.
#
# If you install apache and apache-mod_perl, this is the default config.
# If you don't want two web servers to use perl, uninstall apache, and
# apache-mod_perl will not be proxied.

<IfDefine PERLPROXIED>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^proxy:.* - [F]
RewriteRule ^(.*\/perl\/.*)$ http://%{HTTP_HOST}:8200$1 [P]
RewriteRule ^(.*\/cgi-perl\/.*)$ http://%{HTTP_HOST}:8200$1 [P]
</IfModule>
</IfDefine>

###
### Log configuration Section
###

<IfModule mod_log_config.c>
#Single logfile with access, agent and referer information
#This is the default, if vlogs are not defined for the main server
CustomLog logs/access_log combined env=!VLOG
#If VLOG is defined in conf/vhosts/Vhost.conf, we use this entry
CustomLog "|/usr/sbin/advxsplitlogfile" vhost env=VLOG
</IfModule>

###
### Virtual Hosts
###
# We include different templates for Virtual Hosting. Have a look in the
# vhosts directory and modify to suit your needs.
#Include conf/vhosts/Vhosts.conf
#Include conf/vhosts/DynamicVhosts.conf
#Include conf/vhosts/VirtualHomePages.conf


###
### Performance settings Section
###
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15


# prefork MPM [THIS IS THE DEFAULT]
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

# perchild MPM
# NumServers: constant number of server processes
# StartThreads: initial number of worker threads in each server process
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# MaxThreadsPerChild: maximum number of worker threads in each server process
# MaxRequestsPerChild: maximum number of connections per server process
<IfModule perchild.c>
NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
</IfModule>





I started off using what I thought was the correct configuration in the httpd2.conf file from the example that is given by apache is as follows:

NameVirtualHost 172.20.30.40

<VirtualHost 172.20.30.40>
# primary vhost
DocumentRoot /www/subdomain
RewriteEngine On
RewriteRule ^/.* /www/subdomain/index.html
# ...
</VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
RewriteRule ^(/sub1/.*) /www/subdomain$1
# ...
</VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub2
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
RewriteRule ^(/sub2/.*) /www/subdomain$1
# ...
</VirtualHost>

I have tried a couple different variations on my personal domain name that looked something like this:

This is my main which works fine.
<VirtualHost *:80>
DocumentRoot /home/shadofwack/www
ServerName shadofwack.com
ServerAlias www.shadofwack.com
<Directory "/home/shadofwack/www">
allow from all
</Directory>
<Directory "/home/shadofwack">
allow from all
</Directory>
</VirtualHost>

This is one of the variations i have tried and didnt work.
<VirtualHost *:80>
DocumentRoot /home/shadofwack/www/sub1
ServerName www.sub1.shadofwack.com
ServerPath /sub1/
RewriteEngine On
RewriteRule ^(/sub1/.*) /www/shadofwack$1
# ...
</VirtualHost>

None of the variations I tried seemed to work. I have also tried just putting it in the server name like so:

<VirtualHost *:80>
DocumentRoot /home/shadofwack/sub1/www
ServerName sub1.shadofwack.com
ServerAlias www.sub1.shadofwack.com
<Directory "/home/shadofwack/sub1/www">
allow from all
</Directory>
<Directory "/home/shadofwack/sub1">
allow from all
</Directory>
</VirtualHost>

The final option that i have tried is with just a ServerAlias option like so

<VirtualHost *:80>
DocumentRoot /home/shadofwack/www
ServerName shadofwack.com
ServerAlias *.shadofwack.com
<Directory "/home/shadofwack/www">
allow from all
</Directory>
<Directory "/home/shadofwack">
allow from all
</Directory>
</VirtualHost>

for some reason this last option doesnt seem to work either.

I am really just stuck here. I have seen multiple threads that say these configurations should work, and others that say you have to change things in your DNS. If some one could look through my config and see if im just overlooking something it would be greatly appreciated.

I am about to finish up my computer networking degree, and therefore, as you can probably already tell, very green when it comes to this stuff. Any help would be greatly appreciated!
 
Old 10-24-2006, 05:50 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have you tried just a basic virtual host and then added settings? For example, starting with:
Code:
<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
<Directory "/www/subdomain/sub1">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
</VirtualHost>
I have 2 IP addresses on the box I'm using at the moment, so I use <VirtualHost *:80> instead of <VirtualHost 172.20.30.40>, but apart from that, mine is similar to your setup.
 
Old 10-25-2006, 01:40 AM   #3
sachitanandpandey
LQ Newbie
 
Registered: Dec 2005
Posts: 3

Rep: Reputation: 0
Also u can use ports for multipal domains
 
Old 10-25-2006, 08:11 AM   #4
Wack47
LQ Newbie
 
Registered: Sep 2005
Location: MO
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by gilead
Have you tried just a basic virtual host and then added settings? For example, starting with:
Code:
<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
<Directory "/www/subdomain/sub1">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
</VirtualHost>
I have 2 IP addresses on the box I'm using at the moment, so I use <VirtualHost *:80> instead of <VirtualHost 172.20.30.40>, but apart from that, mine is similar to your setup.

I do use the *:80 the one that you quoted was the example that came from Apache config.
You said you had a similar set up, gilead, do you have subdomains working?
 
Old 10-25-2006, 08:16 AM   #5
Wack47
LQ Newbie
 
Registered: Sep 2005
Location: MO
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sachitanandpandey
Also u can use ports for multipal domains
i have mulitple domains working fine. i just cant get subdomains working at all. Maybe im just not understanding where u are going with this?
 
Old 10-25-2006, 01:34 PM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Quote:
Originally Posted by Wack47
You said you had a similar set up, gilead, do you have subdomains working?
Not quite the same way that you're doing it. I have multiple domains, and multiple hosts on those domains; user1.domain1.com, user2.domain1.com, user3.domain2.com, user4.domain3.com, etc.

I start off with the settings from my earlier post and add more after I get them working. Mainly because requirements change over time, but it also lets me see how each change affects the setup.
 
Old 10-25-2006, 02:02 PM   #7
blong4life
Member
 
Registered: Jun 2006
Distribution: Fedora Core 8, RHEL 4, CentOS 5
Posts: 44

Rep: Reputation: 15
Quote:
Originally Posted by Wack47
i have mulitple domains working fine. i just cant get subdomains working at all. Maybe im just not understanding where u are going with this?

Did you add the subdomain to the nameservers....
 
Old 10-26-2006, 08:37 AM   #8
Wack47
LQ Newbie
 
Registered: Sep 2005
Location: MO
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by blong4life
Did you add the subdomain to the nameservers....

Is that something i have to do in BIND or is that something i have to do at GODADDY?

Thanks for the help so far, and i apologize for my incompetence. I didnt set up the original server, just trying to teach myself, with ya'lls help!
 
Old 10-26-2006, 03:26 PM   #9
blong4life
Member
 
Registered: Jun 2006
Distribution: Fedora Core 8, RHEL 4, CentOS 5
Posts: 44

Rep: Reputation: 15
bind

so you want to add forums.example.com

you nned to go to the example.com file, add

forums A IP

and a reverse, it should be like that havent used bind for linux before, only windows, dont know if there are and differences.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache - running multiple websites on one host xtra Linux - General 5 06-30-2010 04:51 AM
Help with Vhosts in apache please. GEEF Linux - Software 2 10-29-2004 07:18 PM
apache + dns + vhosts albertos Slackware 1 08-03-2003 07:03 PM
apache 2.0.44 vhosts sqn Slackware 4 06-19-2003 12:54 AM
Vhosts on RH 8.0 - Apache 2.0.40 Drogo Linux - Software 5 02-06-2003 11:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration