index.php files ignored

Tony Miller tmiller at thehawkeye.com
Tue Mar 22 08:05:33 PDT 2011


Ryan,

After spending the weekend reading, and poking through the various logs, I came up with a possible solution. In the default httpd.conf file there is the following block:

# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

# I added this block to see if that is what was restricting the files
<Directory /opt/local/apache2/htdocs>
    Order Allow,Deny
    Allow from all
</Directory>

The default was choked down and there was no subsequent allowance for the directory I needed apache to have access to? Does that make sense to you? 

When I started putting back pieces to see if I could isolate the problem, I also discovered that putting the DirectoryIndex block outside the Directory block in the VirtualHost caused me to get the permission error again. This block seems to work:

    <Directory "/opt/local/apache2/htdocs/leopoldheritage">
        AllowOverride None
	<IfModule mod_dav.c>
		DAV Off
	</IfModule>
		Options All -Includes -ExecCGI +MultiViews -Indexes
	<IfModule dir_module>
    		DirectoryIndex index.php index.html
        </IfModule>
    </Directory>

In the problem conf, the <IfModule dir_module> block was under the </Directory> line. Moving it inside the directory block seems to work.

Finally, while working with MacPorts, it began telling me the install was two weeks old and I should run selfupdate, so I did. Now the php files are serving as I would expect and php 5.3.6 is installed, but the php files can no longer connect to MySQL. From the logs it looks like the update has removed a file and the server is unable to start:

110321 22:47:28 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
110321 22:47:28 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
110321 22:47:28 [Warning] The --skip-thread-priority startup option is deprecated and will be removed in MySQL 7.0. MySQL 6.0 and up do not give threads different priorities.
110321 22:47:28 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
/opt/local/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
110321 22:47:28 [ERROR] Aborting

110321 22:47:28 [Note] /opt/local/libexec/mysqld: Shutdown complete

110321 22:47:28 mysqld_safe mysqld from pid file /opt/local/var/db/mysql5/web5.thehawkeye.com.pid ended
110321 22:57:40 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
110321 22:57:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
110321 22:57:40 [Warning] The --skip-thread-priority startup option is deprecated and will be removed in MySQL 7.0. MySQL 6.0 and up do not give threads different priorities.
110321 22:57:40 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive
/opt/local/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
110321 22:57:40 [ERROR] Aborting

110321 22:57:40 [Note] /opt/local/libexec/mysqld: Shutdown complete

110321 22:57:40 mysqld_safe mysqld from pid file /opt/local/var/db/mysql5/web5.thehawkeye.com.pid ended

My question is will doing a port clean install php5-mysql remove the databases? I can restore from backups if so.
Is there an easier way to just redo the mysql and leave php intact?
Finally, is the warning about the file system being case sensitive an issue and could it be causing my missing file woes? Should I reformat and restore to a case insensitive file system?

I hope this may help someone in the future. Thanks in advance.

Tony Miller
tmiller at thehawkeye.com

On Mar 20, 2011, at 5:22 AM, Ryan Schmidt wrote:

> On Mar 19, 2011, at 18:34, Tony Miller wrote:
> 
>>>> I guess 'redirect' is the wrong term. It is really just going to the default virtual host on the server because it is not finding the index.php file. 
>>> 
>>> I agree it's probably using a different virtual host, but not because it's not finding the index.php file. Virtual hosts are independent environments. Apache does not decide, when it cannot find a file in one virtual host, to go looking for it in another.
>> 
>> My understanding is apache will use the default virtual host for the server if it can't find a defined DirectoryIndex file. 
> 
> No, it's easy enough to demonstrate that's not how it works.
> 
> Here's how it works:
> 
> If a request comes in for a hostname or IP address for which there is a virtual host defined, then that virtual host is used. Otherwise, the main host (the one outside any VirtualHost block) is used.
> 
> If there is a directive for any particular setting inside a chosen VirtualHost block, then that directive takes effect. Otherwise, the corresponding directive from the main host is used.
> 
> So if we have:
> 
> ServerName www.example.com
> DocumentRoot /www/main/htdocs
> DirectoryIndex index.html
> 
> <VirtualHost *:80>
> 	ServerName foo.example.com
> 	DocumentRoot /www/foo/htdocs
> 	DirectoryIndex index.php
> </VirtualHost>
> 
> If a request comes in for www.example.com, the main host takes effect and the user is sent the file /www/main/htdocs/index.html. If a request comes in for www2.example.com, and if www2.example.com also maps to this server and does not have a virtual host defined, the main host takes effect in that case too and the user gets the same file.
> 
> If a request comes in for foo.example.com, then that virtual host takes effect. Its directives for DocumentRoot and DirectoryIndex override those of the main host. So the user gets sent /www/foo/htdocs/index.php (after it is evaluated by mod_php). If /www/foo/htdocs/index.php does not exist, the user receives a 403 Forbidden error (if directory listings are off), or the directory listing (if directory listings are on). The server makes no attempt to locate or serve an index.html, because the only directive mentioning index.html has been overridden by this virtual host to no longer mention index.html.
> 
> If you wanted the server to serve index.php if it exists, and index.html otherwise, you would write:
> 
> DirectoryIndex index.php index.html
> 
> The fact you're getting a 404 Not Found, instead of a 403 Forbidden or a directory listing, is interesting... perhaps the entire directory it's looking for is not there, or has insufficient permissions.
> 
> 
>>> What is the full path to this directory?
>> 
>> /opt/local/apache2/htdocs/leopoldheritage
>>> 
> 
> 
>>> I guess the virtual host is not set up correctly. Could you show the Apache virtual host definition for www5.leopoldheritage.org?
>> 
>> <VirtualHost 69.18.41.175:80>
>> ServerName www5.leopoldheritage.org
>> ServerAlias www5.leopoldheritage.org
>> DocumentRoot "/opt/local/apache2/htdocs/leopoldheritage"
>> DirectoryIndex index.php
> 
> That seems correct to me, assuming 69.18.41.175 is in fact the IP address that www5.leopoldheritage.org resolves to. (It does not resolve to anything for me, so I guess it's internal for you). To simplify, you can just put "*" instead of the actual IP address, which also future-proofs you against future IP changes.
> 
>> ErrorLog "logs/web5.thehawkeye.com-error_log"
>> CustomLog "logs/web5.thehawkeye.com-access_log" common
>> 	<IfModule mod_ssl.c>
>> 		SSLEngine Off
>> 		SSLCertificateFile "/etc/certificates/Default.crt"
>> 		SSLCertificateKeyFile "/etc/certificates/Default.key"
>>       SSLProtocol all -SSLv2
>>       SSLCipherSuite "ALL:!ADH:RC4+RSA:+HIGH:!MEDIUM:!LOW:!SSLv2:!EXP"
>> 	</IfModule>
> 
> SSL directives don't belong in this virtual host because this virtual host is defined to operate on port 80, which is for non-encrypted http traffic. SSL-encrypted http traffic (https) would occur on port 443, for which you would make a second virtual host.
> 
>> 	<IfModule mod_dav.c>
>> 		DAVLockDB "/var/run/davlocks/.davlock100"
>> 		DAVMinTimeout 600
>> 	</IfModule>
>> 	<IfModule mod_mem_cache.c>
>> 		CacheEnable mem /
>> 		MCacheSize 4096
>> 	</IfModule>
>> 	<Directory "/opt/local/apache2/htdocs/web5">
> 
> Should this directory be /opt/local/apache2/htdocs/leopoldheritage?
> 
>>       AllowOverride None
>> 		<IfModule mod_dav.c>
>> 			DAV Off
>> 		</IfModule>
>> 		Options All -Includes -ExecCGI +MultiViews -Indexes
>> 	</Directory>
>> 	<IfModule mime_module>
>> 	  AddType html/text	php
> 
> This AddType for php should be deleted.
> 
>> 	  AddType application/x-httpd-php	php
>> 	  AddType application/x-httpd-php-source	phps
> 
> The extensions should begin with a period:
> 
> 	  AddType application/x-httpd-php	.php
> 	  AddType application/x-httpd-php-source	.phps
> 
>> 	</IfModule>
>> <IfModule mod_rewrite.c>
>> 		RewriteEngine On
>> 		RewriteCond %{REQUEST_METHOD} ^TRACE
>> 		RewriteRule .* - [F]
>> 	</IfModule>
> 
> Looks like this mod_rewrite is here to prevent a particular kind of cross-site attack:
> 
> http://www.apacheweek.com/issues/03-01-24#news
> 
> You may want that block in the main part of your Apache configuration file, so it can benefit all your hosts, not just this one.
> 
>> </VirtualHost>
> 
> 
> Check also the access log and error log for clues. When you try to access your hostname, and it says 404 not found, look in the error log to see exactly what file it looked for and couldn't find.
> 
> 
> 
> 
> 



More information about the macports-users mailing list