Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A little help with a virtualhost problem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
kaltag
Tux's lil' helper
Tux's lil' helper


Joined: 28 Apr 2004
Posts: 116
Location: Boise, ID

PostPosted: Sat Nov 20, 2004 9:09 pm    Post subject: A little help with a virtualhost problem Reply with quote

Good afternoon. I'm trying to get 2 different websites running on my gentoo server running apache2. I have the primary page working which is www.newpantheon.com but the other site ww.smellykidgroup.com isn't working correctly, it goes the first site. I have both domain names registered through Yahoo and they are forwarding the domainname to my IP. I was told that it was possible to setup apache to send the traffic to the appropriate virtualhost by looking at the domainname that the request is looking for. I have tried for 3 days now and can't seem to get it working. I hope I'm explaining what I'm trying to do in a way you understand. Here is my vhosts.conf file. I relaize I don't have anything setup in it because I don't know if I need IP based or name based virtual hosts.


#DocumentRoot /home/jmdault/public_html
#ServerName test2.com
#Setenv VLOG /home/jmdault/logs
#ErrorLogs /home/jmdault/test2-error_log
#RewriteEngine On
#RewriteOptions inherit
#</VirtualHost>

################# Named VirtualHosts
#NameVirtualHost 111.222.33.44
#<VirtualHost 111.222.33.44>
#ServerName www.domain.tld
#ServerPath /domain
#DocumentRoot /web/domain
#</VirtualHost>

Here is my apache2.conf file

### /etc/apache2/conf/apache2.conf
### $Id: apache2.conf,v 1.1 2004/03/22 21:17:57 stuart Exp $
###
### Main Configuration Section
### You really shouldn't change these settings unless you're a guru
###
ServerRoot /usr/lib/apache2
ServerName server
#LockFile /etc/apache2/apache2.lock
PidFile /var/run/apache2.pid
ErrorLog logs/error_log
LogLevel warn
DocumentRoot /var/www/localhost/htdocs

### Dynamic Shared Object (DSO) Support
###
### You should always leave these 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 include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.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 proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.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

###
### New Modules for 2.0 (some are experimental)
###
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule echo_module modules/mod_echo.so
LoadModule charset_lite_module modules/mod_charset_lite.so
LoadModule cache_module modules/mod_cache.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule case_filter_module modules/mod_case_filter.so
LoadModule case_filter_in_module modules/mod_case_filter_in.so
LoadModule deflate_module modules/mod_deflate.so
#LoadModule optional_hook_export_module modules/mod_optional_hook_export.so
#LoadModule optional_hook_import_module modules/mod_optional_hook_import.so
#LoadModule optional_fn_import_module modules/mod_optional_fn_import.so
#LoadModule optional_fn_export_module modules/mod_optional_fn_export.so
#LoadModule bucketeer_module modules/mod_bucketeer.so
LoadModule logio_module modules/mod_logio.so

###
### Global Configuration
###
# Splitting up apache2.conf into two files makes it easier to support
# multiple configurations on the same serer. In commonapache2.conf
# you keep directives that apply to all implementations and in this
# file you keep server-specific directives. While we don't yet have
# multiple configurations out-of-the-box, this allows us to do that
# in the future easily. (PERLPROXIED *ahem*)
#
# For Apache2 we load all conf files in conf/modules.d
Include conf/modules.d/*.conf
Include conf/commonapache2.conf

###
### IP Address/Port
###
#BindAddress *
Listen *:80

###
### 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/vhosts.conf, we use this entry
#CustomLog "|/usr/sbin/apache2splitlogfile" 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/dynamic-vhosts.conf
Include conf/vhosts/virtual-homepages.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>

<VirtualHost smellykidgroup.com>
DocumentRoot "/var/www/skg"
ServerName smellykidgroup.com
<Directory "/var/www/skg">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

I appologize for the long post and any help is appreciated. If anyone knows of a site that has a useful HOWTO or guide on what I'm trying to setup I would GREATLY appreciate it. Thank you.
_________________
Yeah, I know about the recovery console. Usually, it doesn't do anything more than I can do with a match, a weedwhacker, and a sledgehammer. Actually, it does a whole lot less. - Caffinehog
Back to top
View user's profile Send private message
seank
l33t
l33t


Joined: 08 Jul 2004
Posts: 686

PostPosted: Sat Nov 20, 2004 10:35 pm    Post subject: Reply with quote

Your conf should look something like this:
Code:
NameVirtualHost *:80
<VirtualHost *:80>
   DocumentRoot /var/www/skg
   ServerName smellykidgroup.com
   <Directory "/var/www/skg">
      Allow from all
      Options +Indexes
   </Directory>
</VirtualHost>
Back to top
View user's profile Send private message
kaltag
Tux's lil' helper
Tux's lil' helper


Joined: 28 Apr 2004
Posts: 116
Location: Boise, ID

PostPosted: Sun Nov 21, 2004 1:44 am    Post subject: Reply with quote

Thanks. That almost has it running now. If I have a single entry in the vhosts.conf file it will work for either site but not both. Is there anything I have to modify in the apache2.conf file? When I restart apache I get a warning but it still runs that says "[Sat Nov 20 19:47:04 2004] [warn] NameVirtualHost *:80 has no VirtualHosts" Here is my updated vhosts.conf file.

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/localhost/htdocs
ServerName newpantheon.com
<Directory "/var/www/localhost/htdocs">
Allow from all
Options +Indexes
</Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/skg
ServerName smellykidgroup.com
<Directory "/var/www/skg">
Allow from all
Options +Indexes
</Directory>
</VirtualHost>
_________________
Yeah, I know about the recovery console. Usually, it doesn't do anything more than I can do with a match, a weedwhacker, and a sledgehammer. Actually, it does a whole lot less. - Caffinehog
Back to top
View user's profile Send private message
seank
l33t
l33t


Joined: 08 Jul 2004
Posts: 686

PostPosted: Sun Nov 21, 2004 1:54 am    Post subject: Reply with quote

You don't need 2 NameVirtualHost *:80 -- just put 1 at the top.
Back to top
View user's profile Send private message
kaltag
Tux's lil' helper
Tux's lil' helper


Joined: 28 Apr 2004
Posts: 116
Location: Boise, ID

PostPosted: Sun Nov 21, 2004 3:55 am    Post subject: Reply with quote

Thanks again. That fixed the apache warning error. I am still having the problem with only the first host in the list comming up. In other words www.newpantheon.com and www.smellykidgroup.com both bring up the newpantheon.com site unless I have the smellykidgroup.com virtualhost first then smellykidgroup.com comes up for both sites. Any ideas what might be going on there?
_________________
Yeah, I know about the recovery console. Usually, it doesn't do anything more than I can do with a match, a weedwhacker, and a sledgehammer. Actually, it does a whole lot less. - Caffinehog
Back to top
View user's profile Send private message
nightcanton
Apprentice
Apprentice


Joined: 26 Feb 2003
Posts: 249

PostPosted: Sun Mar 20, 2005 2:34 am    Post subject: Reply with quote

I have the same issue as well. I'm trying to figure it out.
Back to top
View user's profile Send private message
midknight_gentoo
n00b
n00b


Joined: 13 Jul 2003
Posts: 22

PostPosted: Sun Mar 20, 2005 3:35 am    Post subject: Reply with quote

instead of *:80

i use the ip of the server..
ie: 10.10.10.150:80

for both the name directive and the virtual hosts.... works like a treat.
Back to top
View user's profile Send private message
nightcanton
Apprentice
Apprentice


Joined: 26 Feb 2003
Posts: 249

PostPosted: Mon Mar 21, 2005 12:31 am    Post subject: Reply with quote

Quote:
NameVirtualHost 192.168.0.6:80>
<VirtualHost 192.168.0.6:80>
ServerName jump.com
ServerAlias www.jump.com
ServerAdmin luke@jump.com
DocumentRoot /var/www/localhost/htdocs
<Directory "/var/www/localhost/htdocs">
AllowOverride All
Options +Indexes
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
Setenv VLOG /var/log/apache/
ErrorLog /var/log/apache/jump_com_error_log
CustomLog /var/log/apache/jump_com_access_log combined
</VirtualHost>
<VirtualHost 192.168.0.6:80>
ServerName online.com
ServerAlias www.online.com
ServerAdmin luke@online.com
DocumentRoot /var/www/wkt/htdocs
<Directory "/var/www/wkt/htdocs">
AllowOverride All
Options +Indexes
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
Setenv VLOG /var/log/apache/
ErrorLog /var/log/apache/online_com_error_log
CustomLog /var/log/apache/online_com_access_log combined
</VirtualHost>


I tried putting the main domain, which is the server name, jump.com as the virtual host instead of 192.168.0.6 but it had the same result. I still get jump.com's stuff when trying to access online.com's material. But when I type int online.com I get the outside IP address.

Any Ideas?
Back to top
View user's profile Send private message
nightcanton
Apprentice
Apprentice


Joined: 26 Feb 2003
Posts: 249

PostPosted: Mon Mar 21, 2005 8:30 pm    Post subject: Reply with quote

Quote:


ServerType standalone
ServerRoot /etc/apache
#ServerName localhost
#LockFile /etc/httpd/httpd.lock
PidFile /var/run/apache.pid
ScoreBoardFile /etc/apache/apache.scoreboard
ErrorLog logs/error_log
LogLevel warn
ResourceConfig /dev/null
AccessConfig /dev/null
DocumentRoot /var/www/localhost/htdocs


LoadModule mmap_static_module modules/mod_mmap_static.so
LoadModule env_module modules/mod_env.so
LoadModule config_log_module modules/mod_log_config.so
LoadModule agent_log_module modules/mod_log_agent.so
LoadModule referer_log_module modules/mod_log_referer.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule status_module modules/mod_status.so
LoadModule info_module modules/mod_info.so
LoadModule includes_module modules/mod_include.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule asis_module modules/mod_asis.so
LoadModule imap_module modules/mod_imap.so
LoadModule action_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule proxy_module modules/libproxy.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule access_module modules/mod_access.so
LoadModule auth_module modules/mod_auth.so
LoadModule anon_auth_module modules/mod_auth_anon.so
LoadModule dbm_auth_module modules/mod_auth_dbm.so
LoadModule db_auth_module modules/mod_auth_db.so
LoadModule digest_module modules/mod_digest.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 example_module modules/mod_example.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so


ClearModuleList
AddModule mod_mmap_static.c
AddModule mod_env.c
AddModule mod_log_config.c
AddModule mod_log_agent.c
AddModule mod_log_referer.c
AddModule mod_mime_magic.c
AddModule mod_mime.c
AddModule mod_negotiation.c
AddModule mod_status.c
AddModule mod_info.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
AddModule mod_speling.c
AddModule mod_userdir.c
AddModule mod_proxy.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
AddModule mod_auth_anon.c
AddModule mod_auth_dbm.c
AddModule mod_auth_db.c
AddModule mod_digest.c
AddModule mod_cern_meta.c
AddModule mod_expires.c
AddModule mod_headers.c
AddModule mod_usertrack.c
AddModule mod_example.c
AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c
AddModule mod_vhost_alias.c

Include conf/commonapache.conf
Port 80
Listen 80
CustomLog logs/access_log combined env=!VLOG

### 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
#NameVirtualHost *:80

Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 4
MaxSpareServers 10
StartServers 4
MaxClients 150
MaxRequestsPerChild 500


Above is my apache.conf

Below is my Vhosts.conf
Quote:

Port 80
ServerRoot /etc/apache
ResourceConfig /dev/null
AccessConfig /dev/null

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
ServerName www.jump.com
ServerAlias jump.com
DocumentRoot /var/www/localhost/htdocs
ErrorLog /var/log/apache/lukeerrorlog
</VirtualHost>

<VirtualHost 127.0.0.1:80>
ServerName www.online.com
ServerAlias online.com
DocumentRoot /var/www/wkt/htdocs
ErrorLog /var/log/apache/wkterrorlog
</VirtualHost>




I tried not using the Vhosts.conf file and just putting the information into the apache.conf. But that didn't work either.

Any Ideas?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum