Forum Moderators: bakedjake
However, on our new server I noticed all vhosts are separated into their own vhost files (new to me)... and I can go into the vhost files and add an alias for the IP address - but the server doesn't know to look into that particular vhost file for that IP address.
I'm missing a connection somewhere - I'm thinking it probably goes in the httpd.conf... but I don't know what to put there.
Any help would be greatly appreciated so I can access sites by IP as well as by domain name.
OH...also - side question - is it necessary to have all vhosts in separate files? I have multiple sites, but I'm the only one using our new dedicated.
Also, are you running Apache 1.3 or 2.0? Am I right in believeing RHES uses Apache 2.0 by default? Are you using the graphical administration tool or editing the files by hand?
The standard setup for virtual hosts is detailed here [httpd.apache.org], and I'm sure you know the reference guide [redhat.com] for Apache 2.0 on RHES already.
You might also want to check out the section of the Apache documentation called Dynamically configured mass virtual hosting [httpd.apache.org]: it might just be what you're looking for if you're setting up each virtual host in a /home directory. I've not tried it, but it looks promising as a method of managing the virtual hosts more easily as you don't need to set up each one individually.
The online manual you referred me to "Dynamically configured mass virtual hosting" is for "Name" base hosting which allows you to have many domain names using a single IP address - which seems like what RH ES is already setup to do (name based hosting).
All of my domains will have their very own IP address - what I want to do is make it so I can access the site via IP address AND domain name - but currently, it seems like RH is setup (out of the box) to use name base hosting only.
----------------------------------------------
Here are snippets from my "httpd.conf" file that refer to vhosts
Include conf.d/*.conf
Include conf/vhosts/ssl
Include conf/vhosts/normal
-----------------------------------------------
Here is a sample vhost file in (conf/vhosts/normal)
conf/vhosts/normal/domain-name.com:80
NameVirtualHost *:80
ServerRoot /etc/httpd
<VirtualHost *:80>
ServerName domain-name.com
ServerAlias www.domain-name.com
ServerAlias 111.111.111.111
ServerAdmin webmaster@domain-name.com
DocumentRoot /home/domain-name/htdocs
LogFormat COMBINED
ErrorLog /home/domain-name/htdocs/logs/error_log
TransferLog /home/domain-name/htdocs/logs/access_log
</VirtualHost>
------------------------------------------------
This is a little different than I am used to with Apache on FreeBSD (first 3 lines are different).
Anyway, any clue why it is not serving pages by IP address. The only thing that comes up is the default Apache page (when there are no sites setup). One question you may ask is if it works by (domain name) - well, I don't know.... cause I can't switch our domains over until I KNOW this new server is working - so I have to work by IP address for testing. I've had the server for a week now and still can't test so any assistance would be GREATLY appreciated! :D
NameVirtualHost 111.111.111.111:80
NameVirtualHost 222.222.222.222:80
ServerRoot /etc/httpd
<VirtualHost 111.111.111.111:80>
ServerName domain-name.com
ServerAlias www.domain-name.com
ServerAlias 111.111.111.111
ServerAdmin webmaster@domain-name.com
DocumentRoot /home/domain-name/htdocs
LogFormat COMBINED
ErrorLog /home/domain-name/htdocs/logs/error_log
TransferLog /home/domain-name/htdocs/logs/access_log
</VirtualHost>
<VirtualHost 222.222.222.222:80>
ServerName domain-name.com
ServerAlias www.domain-name.com
ServerAlias 222.222.222.222
ServerAdmin webmaster@domain-name.com
DocumentRoot /home/domain-name/htdocs
LogFormat COMBINED
ErrorLog /home/domain-name/htdocs/logs/error_log
TransferLog /home/domain-name/htdocs/logs/access_log
</VirtualHost>
The 111.111.111.111:80 rather than *:80 binds that VHost to a specific IP only, rather than listening on all IPs.
Although I don't think the ServerAlias IP.Ad.dr.ess is necessary.
Also, this might be answered more quickly if you also ask in the Apache forum.
-MM
Include conf.d/*.conf
Include conf/vhosts/ssl
Include conf/vhosts/normal
Am I right in assuming that these includes are pointing to directories rather than files? Are your individual files then in these directories?
Looking at the Apache 2 documentation, I found this:
[httpd.apache.org...]
Specifically:
In addition, if Include points to a directory, rather than a file, Apache will read all files in that directory and any subdirectory. But including entire directories is not recommended, because it is easy to accidentally leave temporary files in a directory that can cause httpd to fail.
Try changing httpd.conf to read:
Include conf/vhosts/vhosts.conf instead of the two virtual host directories, then place all your virtual hosts in the vhosts.conf file. Much easier than maintaining separate files for each!
I've often found it strange how RedHat modifies its httpd.conf from the standard one, but after a little digging, you can see the patterns. :)
Really all you'd need to do, if you wanted to set it up that each VHost has a different config file (sometimes useful), just create the files in "conf.d/", named like "vhost1.conf vhost2.conf" etc. They'll all be included automatically at the next restart/startup, due to the "Include conf.d/*.conf" line.
-MM