Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to set up a virtual host on Apache2 (CentOS 5) but instead of the default site or the virtual site, all I am getting is the Apache test page.
Listen 192.168.0.250:80
ServerName webserver:80
UseCanonicalName Off
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
Allow Override None
Order allow,deny
Allow from all
</Directory>
<FilesMatch "^\.">
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch "~$">
Order allow,deny
Deny from all
</FilesMatch>
HostnameLookups Off
NameVirtualHost 192.168.0.250:80
<VirtualHost 192.168.0.250:80>
DocumentRoot /var/www/vhost/intranet
ServerName intranet
ServerAlias intranet.domain.local
AddType application/x-httpd-php .php
</VirtualHost>
<Directory /var/www/vhosts/intranet>
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
Permissions for the folders:
Code:
drwxr-xr-x 2 apache apache 4096 Dec 10 14:13 /var/www/html
drwxr-xr-x 11 apache apache 4096 Dec 7 14:41 /var/www/vhosts/intranet
Any ideas what I'm doing wrong? Cheers.
Last edited by intramaweb; 12-11-2007 at 08:16 AM.
Reason: Added folder permissions
NameVirtualHost 192.168.0.250:80
<VirtualHost 192.168.0.250:80>
DocumentRoot /var/www/vhost/intranet
ServerName intranet
ServerAlias intranet.domain.local
AddType application/x-httpd-php .php
</VirtualHost>
<Directory /var/www/vhosts/intranet>
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
To:
Code:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/vhost/intranet
ServerName intranet
ServerAlias intranet.domain.local
ServerPath /intranet
AddType application/x-httpd-php .php
<Directory /var/www/vhosts/intranet>
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Basically for vhosts, always put any <Directory> tags within the VirtualHost it's intended for, just makes things easier to understand and read.
Secondly, if you only have one IP address, no reason to put it in the NameVirtualHost and VirtualHost, a simple *:80 will do just fine.
And In Apache2, I found with virtual hosts, it's best to use the ServerPath so it knows where to find the directory cause for some odd reason it reverts back to the main configurations document root.
ServerPath = Legacy URL pathname for a name-based virtual host that is accessed by an incompatible browser
Thanks for the tips. I've made all these changes but unfortunately, I still have the same problem.
I'm thinking that the problem must not be with the vhosts, as browsing to http://webserver/ aught to show me what's in the DocumentRoot but this is also just showing me the test page.
My understanding of the test page is that it redirects a 403 error to the the test page location so I thought there might be a permissions problem but I've tried both the commands below on the DocumentRoot path and on the vhost path to no avail
Whenever I have virtual hosts, I always make a virtual host for the main configuration as well. Try that. If you don't need the test page though, just make your main configuration and document root the one you intend to use as well.
Try typing 'setenforce 0' at the command prompt as root on the webserver.
This will temporarily turn off SELinux's enforcing. If it works after doing this, then you need to look at your SELinux policies on the files you're trying to serve.
Unfortunately I can't help you any further with that!
PS. to turn enforcing back on, type 'setenforce 1'.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.