[CentOS] Virtual Hosts question

Thu Feb 6 17:14:45 UTC 2014
Paul Heinlein <heinlein at madboa.com>

On Thu, 6 Feb 2014, Joseph Hesse wrote:

> I am running Wordpress on a CentOS 6.5 server which is behind a router.
> The private IP is 192.168.0.99, the public URL is X.com (name changed).
>
> I have two virtual hosts in my httpd.conf file.  The second one, listed
> below, is for Wordpress and it is accessed with http://X.com/d4i or
> http://www.X.com/d4i. They work fine.
>
> Actually, not show, I have more Wordpress virtual hosts, and they are
> accessed with http://X.com/s1, http://X.com/s2, etc. and they work.
>
> I want the first virtual host to be a default and accessed whenever a
> user types http://X.com (no sub directory).  There is a valid
> /var/www/html/index.html file.
>
> Unfortunately it doesn't work.  The error is "Directory index forbidden
> by Options directive: /var/www/wordpress/" and googling didn't help.
>
> I have my httpd.conf and error.log below.
>
> Thank you, Joe
>
> ============== httpd.conf ==============
> ServerName 192.168.0.99
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
>  ServerName IDoNotExist.com
>  DocumentRoot /var/www/html
>  DirectoryIndex Index.html index.html
> </VirtualHost>

Since the ServerName for your first virtual host is NOT X.com, no one 
will get to this virtual host unless they specify the IP address 
associated with X.com, so /var/www/html won't be the DocumentRoot for 
people attempting to reach X.com.

> <VirtualHost *:80>
>  ServerName X.com
>  ServerAlias www.X.com
>  DocumentRoot /var/www/wordpress
>  DirectoryIndex Index.html index.html index.php Index.php
>  CustomLog logs/access_log_custom common
> </VirtualHost>

Here's the host people will reach via http://X.com/.

My first guess is that the Unix permissions on /var/www/wordpress or 
the index.php file within it are too restrictive.

My second guess is that the SELinux labels for them might be 
incorrect.

My third guess is that there's a restriction somewhere in the 
httpd.conf that you didn't snip for us.

> ============== httpd.conf ==============

-- 
Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W