Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Virtual name host not working apache/mindrake

Status
Not open for further replies.

zoomforce

Technical User
Jan 6, 2002
70
CA
Hey.. i am having some problems and the apache documentation is pretty useless to me..

Here goes....

Apache on my system was installed in the VAR folder instead of the USR folder that every documentation seems to mention.. i think this is a mandrake thing..?

but anyways, i wanna use virtual hosts, and i went to the http.conf file and it kinda points to a vhost.conf file in the etc/http/conf/vhost folder.. so in the Vhosts.conf I added the following

namevirtualhost 142.173.111.209
<virtualhost 142.173.111.209>
Servername DocumentRoot /home/ninja/www
</virtualHost>

I have a dns service that points the domain to the server IP, and i want that domain to point to the /home/ninja/ but its not working. when i type seekbetter.com in the browser it just goes to the default htm folder.

HHHHMMMMPPPPPHHH. I am so frustrated. Thanks in advance to anyone who can solve my woes. Thanks!
 
If that is exactly how you have it in your vhost.conf file, you should try the following.
NameVirtualHost 142.173.111.209
<VirtualHost 142.173.111.209>
ServerName DocumentRoot /home/ninja/www
</VirtualHost> //Daniel
 
lol sorry, i forgot punctuation when i entered this post.. but no that's not the problem.. thanks though. any other ideas? I dont understand why im such as dumbass
 
How does the line look where httpd.conf points to the vhost.conf? And what version of Apache are you using? //Daniel
 
I am using the apache verion that comes with mandrake 7.1 a am presuming its the newest.. im not sure how to check version number

and the http conf line looks like this

###
### Virtual Hosts
###
# we include differnet 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

whehh that was a pain to type :)
 
First of all, what version of apache are you using? The vhost.conf seems to be old school. Versions since 1.3 have tried to clean things up by putting all the .conf files such as srm.conf, access.conf and so on into one httpd.conf file. Anyway, I think you can get by with using vhost containers in httpd.conf. To set up apache you should just have to edit that one file. I don't like most of the programs that say they cofigure apache because they sometimes leave out a few things and you have a heck of a time trying to find a problem later. If you have a fresh copy of httpd.conf make a backup and save it so you can go back to it if you ever have to start from scratch. Load httpd.conf in a text editor. The first line you have to check is:
ServerType standalone
The option here is standalone or inetd. If you use inetd, then it will run as a daemon under xinetd. The next line is:
ServerRoot &quot;/etc/httpd&quot;
The server root is where apache keeps it's .conf files logs and modules. It has nothing to do with your server pages. The next line you need to look at is ServerName. This directive will be used in your vhost containers but here in the main it will not be served so you can leave it at localhost or whatever. The rest of the file has the DocumentRoot and all the other directories for your website. Like I said, these will not be served and will have to be redefined in your vhost containers. If you have only one ip address you will need to use name based virtual hosts. In order for this to work your dns service needs to point all your virtual hosts to your ip address. If that's cool, let's set up your vhosts. The following is just an example. You can use any directories you want. You just have to create the directories that you define.

UseCanonicalName Off

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@youdomain.com
ServerName
DocumentRoot /var/
<Directory &quot;/var/ Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/var/
<Directory &quot;/var/ AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

</VirtualHost>


<VirtualHost *>

ServerAdmin webmaster@vhost2.domain.com
DocumentRoot /var/ ScriptAlias /cgi-bin/ /var/ ServerName vhost2.domain.com

</VirtualHost>

I didn't fill in the containers for vhost2 because I figured you'd get the idea. This will get you started so I wouldn't worry about all the other stuff yet. You may have to come back and get help with the fine tuning. Good luck.
 
RhytymeAce, your the kind of person tha makes this world so great. Thanks for the help.

so, I guess I have an old apache. I will try and upgrade it, I am not sure how to but i'm sure i will figure it out. Mandrake even has a update thing that might do it (this is my second day of Linux)

I will try and install a newer version, and try your suggsetsion. thanks again!
sorry for spelling mistakes, im typing in the dark :)
 
I just checked my apache.. it says 1.3.22-1
Is that new?

I think it might be the way mindrake installs it.. if i uninstall it (i figured out that part) how do i install it from downloading it from apache.org? It comes as a tar file, i can unpack them but so far i only know how to install programs that are rma or something (some sort of installer) Is there an easier way then going into the shell and unpacking and etc? I know this is a newbie newbie question, dont waste your time answering this one cause i can figure that part out if it requires an explanation.

I have a feeling it would at least put thiungs in the right directories.

Here is my http.conf file as it is now:



### Main Configuration Section
### You really shouldn't change these settings unless you're a guru
###
ServerType standalone
ServerRoot /etc/httpd
#ServerName localhost
#LockFile /etc/httpd/httpd.lock
PidFile /var/run/httpd.pid
ScoreBoardFile /etc/httpd/httpd.scoreboard
ErrorLog logs/error_log
LogLevel warn
ResourceConfig /dev/null
AccessConfig /dev/null



### Dynamic Shared Object (DSO) Support
###
###
#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
<IfDefine HAVE_SSL>
LoadModule ssl_module extramodules/libssl.so
</IfDefine>
LoadModule vhost_alias_module modules/mod_vhost_alias.so

# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]
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
<IfDefine HAVE_SSL>
AddModule mod_ssl.c
</IfDefine>
AddModule mod_vhost_alias.c

###
### 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.)
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>
Port 80
Listen 80
</IfDefine>
<IfDefine APACHEPROXIED>
Port 8080
Listen 8080
</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>
RewriteEngine on
RewriteRule ^proxy:.* - [F]
RewriteRule ^(.*\/perl\/.*)$ [P]
RewriteRule ^(.*\/cgi-perl\/.*)$ [P]
</IfDefine>

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

#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 &quot;|/usr/sbin/advxsplitlogfile&quot; vhost 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


###
### 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 &quot;Off&quot; 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

#
# Server-pool size regulation. Rather than making you guess how many
# server processes you need, Apache dynamically adapts to the load it
# sees --- that is, it tries to maintain enough server processes to
# handle the current load, plus a few spare servers to handle transient
# load spikes (e.g., multiple simultaneous requests from a single
# Netscape browser).
#
# It does this by periodically checking how many servers are waiting
# for a request. If there are fewer than MinSpareServers, it creates
# a new spare. If there are more than MaxSpareServers, some of the
# spares die off. The default values are probably OK for most sites.
#
MinSpareServers 4
MaxSpareServers 10

#
# Number of servers to start initially --- should be a reasonable ballpark
# figure.
#
StartServers 4

#
# Limit on total number of servers running, i.e., limit on the number
# of clients who can simultaneously connect --- if this limit is ever
# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
# It is intended mainly as a brake to keep a runaway server from taking
# the system with it as it spirals down...
#
MaxClients 150

#
# MaxRequestsPerChild: the number of requests each child process is
# allowed to process before the child dies. The child will exit so
# as to avoid problems after prolonged use when Apache (and maybe the
# libraries it uses) leak memory or other resources. On most systems, this
# isn't really needed, but a few (such as Solaris) do have notable leaks
# in the libraries. For these platforms, set to something like 10000
# or so; a setting of 0 means unlimited.
#
# NOTE: This value does not include keepalive requests after the initial
# request per connection. For example, if a child process handles
# an initial request and 10 subsequent &quot;keptalive&quot; requests, it
# would only count as 1 request towards this limit.
#
MaxRequestsPerChild 500

Include conf/ssl/mod_ssl.conf
Include conf/ssl/ssl.default-vhost.conf
 
You have the latest stable version. There is a ver. 2.0 but I'd let the big boys sweat out the bugs. :eek:) It looks like you just have to put the containers in the vhost.conf file and you're all set. You may want to read up on the different types though. It looks like they have one for dynamic IPs and so on. In my version, I have to tell apache if I'm using ip based or name based virtual hosting. Your version may use a differnt type of vhost.conf file. To answer you question about installing tarballs, most of them install the same way. First you unzip the bad boy with a command tar -zxvf *.gz and it will unzip then untar the file into its own directory. Then to compile and install the program you type ./configure from the source directory to configure the package to your system. Then you type make to compile the program and finally type make install to install it. No problem. In some cases, you may have to run ldconfig if it uses shared object libraries but that's rare. I think you should have your server up and running before the lights come back on. :eek:)
 
Thanks for the extra info!

I did try and put them in the vhost.cfg file, look at my first thread to see what i did.. but that didnt work. should i try the one you made?
 
here is my current vhosts.conf :

################# Vhosts.conf
#This is where we store the VirtualHosts configuration.
#
#Since Apache 1.3.19, we modified the setup to include some nice tricks:
#
#- We added the User and Group directives so VirtualHosts now work with
# suexec directive. If set, Apache will run all cgi scripts under that
# user and group (provided the uid and gid are > 100 for security). The
# directories and cgi files *must* belong to that user/group for the
# feature to work
#- We added the Setenv VLOG directive. This works in conjunction with
# the CustomLog in common.conf. When Setenv VLOG is set, apache will
# create a /var/log/httpd/VLOG-YYYY-MM-<ServerName>.log instead of logging
# to access_log. Use this instead of defining a special logfile for
# each vhost, otherwise you eat up file descriptors.
#- You can also specify a path for the VLOG for each Vhost, for example,
# to place the logs in each user's directory. However, if you want to
# use the file for accounting, place it in a directory owned by root,
# otherwise the user will be able to erase it.
#- I suggest only including the ErrorLog *only* if the vhost will use
# cgi scripts. Again, it saves file descriptors!
#- We added the Rewrite directives so vhosts will work with the
# PERLPROXIED configuration

################# IP-based Virtual Hosts
#<VirtualHost 192.168.2.100>
#User jmdault
#Group jmdault
#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 142.173.111.209
<VirtualHost 142.173.111.209>
ServerName DocumentRoot /home/ninja/www
</VirtualHost>
 
i added all that container stuff to vhosts...and it still defaults back to my index directory... man o man
 
this is the new vhosts.conf:


################# Vhosts.conf
#This is where we store the VirtualHosts configuration.
#
#Since Apache 1.3.19, we modified the setup to include some nice tricks:
#
#- We added the User and Group directives so VirtualHosts now work with
# suexec directive. If set, Apache will run all cgi scripts under that
# user and group (provided the uid and gid are > 100 for security). The
# directories and cgi files *must* belong to that user/group for the
# feature to work
#- We added the Setenv VLOG directive. This works in conjunction with
# the CustomLog in common.conf. When Setenv VLOG is set, apache will
# create a /var/log/httpd/VLOG-YYYY-MM-<ServerName>.log instead of logging
# to access_log. Use this instead of defining a special logfile for
# each vhost, otherwise you eat up file descriptors.
#- You can also specify a path for the VLOG for each Vhost, for example,
# to place the logs in each user's directory. However, if you want to
# use the file for accounting, place it in a directory owned by root,
# otherwise the user will be able to erase it.
#- I suggest only including the ErrorLog *only* if the vhost will use
# cgi scripts. Again, it saves file descriptors!
#- We added the Rewrite directives so vhosts will work with the
# PERLPROXIED configuration

################# IP-based Virtual Hosts
#<VirtualHost 192.168.2.100>
#User jmdault
#Group jmdault
#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
UseCanonicalName Off

NameVirtualHost *

<VirtualHost *>

ServerAdmin webmaster@seekbetter.com
ServerName
DocumentRoot /var/
<Directory &quot;/var/ Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ScriptAlias /cgi-bin/ &quot;/var/
<Directory &quot;/var/ AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

</VirtualHost>
 
Hi,

Mandrake does set it up a bit differently to most others. As you probably worked out, the main http.conf file has directives to 'include' external files for certain chunks of content that would normally be found directly in httpd.conf - i.e. :

/etc/httpd/conf/addon-modules
/etc/httpd/conf/apache-mime.types
/etc/httpd/conf/commonhttpd.conf
/etc/httpd/conf/httpd-perl.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/vhosts/DynamicVhosts.conf
/etc/httpd/conf/vhosts/Vhosts.conf
/etc/httpd/conf/vhosts/VirtualHomePages.conf

However, as long as these files are included and syntactically correct it should not make any difference. You can check the syntax by doing :

/usr/sbin/httpd -t

I would try putting 'UseCanonicalName Off' within the vhost container and keeping it as simple as possible until you get it working - e.g.

NameVirtualHost *

<VirtualHost *>
UseCanonicalName off
ServerName DocumentRoot /var/</VirtualHost>

<VirtualHost *>
UseCanonicalName off
ServerName DocumentRoot /var/</VirtualHost>

Remember you have to signal Apache to reload the config after any change unless you stop/start the server, i.e. :

killall -HUP httpd

Also, make sure you are using an up-to-date browser for testing because old versions of netscape, etc., are not http/1.1 compliant and name-based virtual hosting relies on the browser filling in the 'host:' field in the http header.

Hope this helps
 
well, i never knew you had to restart the server, thats probally half my battle.
 
well, thank you everyone, turns out bloody hell that it was becasue i didnt restart the server.... it all works now :)
 
ok one more question.. I know im pushing my luck hee hee

I want the vhosts to point to a home/user/http/ folder outside the var folder where the default website is, can i do this in the vhosts without any issues? I am not sure if there are permission problems or anything.

I want to do this so all documentation i have will make more sense, as well be able to ftp my files, as when they are in the var folder, I havn't been able to figure out how to log in with permissions to change things.
 
You can do just about anything you want as far as placing your website goes. I wouldn't mess with apache itself or it's components, but your websites can be any where on your machine you want. I would use the following guidelines. Keep all you r web directories together for easier administration under one main directory. For example, create a directory off of your root partion called /web or /www. Then create directories under that for all your sites i.e. / / etc. Then inside each of these set up some directories like / and / and so on. A setup like this makes it a lot easier to edit your vhost.conf file. Once you create the first vhost container in vhost.conf, you can copy and paste your containers and just have to edit the name in the path and ServerName etc.
 
yes, you have been tremendous help... I love it!
everything seems to be a ok, and i will setthings up like you said. one question, if i make it in a folder off route, how to i log in over FTP to modify update files? I fugred out how to do it if i make the in a home usr directory..
 
I'm not sure what you are asking. Do you want users to be able to access their own website via ftp? Red Hat's version of apache can setup an account in each users $HOME directory with a container somthing like the following:

#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# <Limit GET POST OPTIONS PROPFIND>
# Order allow,deny
# Allow from all
# </Limit>
# <LimitExcept GET POST OPTIONS PROPFIND>
# Order deny,allow
# Deny from all
# </LimitExcept>
#</Directory>

In your case it looks like you would use
#Include conf/vhosts/VirtualHomePages.conf instead of vhosts.conf. I wish I knew more about mandrake but maybe you know enough to figure it out. If this works for you, then you shouldn't have to do a lot to your ftp server because the default directory is the users home directory. They will however be able to change to other directories unless you put some resrtictions in. I'd try to see if it works first then set restrictions later.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top