PDA

View Full Version : Apache help



ubermorlock
17th August 2011, 03:42 PM
I need to set my apache and php installs up to serve both .php and .php5 files. The reason for the odd .php5 extension is because one of the servers I have to interact with uses .php5 to determine that it should use php v5.x to interpret the file instead of using php v4.x. If I add 'index.php5' to this section in /etc/httpd/conf/httpd.conf :

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var index.php index.php5

Then the server will only interpret php5 files and not php files.

I have also modified the following sections of /etc/httpd/conf.d/php.conf:

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php, .php5
AddType text/html .php, .php5, .html

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php index.php5

Appreciate the help. I'm not sure how to solve this and I know it is an odd problem. I recall having solved it in F11, but it has been a very long time since I did that (and I upgraded direct from F11 to F14 via a clean install).

EDIT: A little further testing has revealed the problem to be in php.conf. When I remove .php5 from the 'AddHandler' line, then it serves .php files just fine. When I add .php5 back into that line, then it will serve .php5 files fine and fail to interpret .php files, instead.

ubermorlock
23rd August 2011, 05:03 PM
OK. I did some more work on this and found the solution. I had to edit my /etc/httpd/conf.d/php.conf file like so (line numbers added for easy reference here):

1 #
2 # Cause the PHP interpreter to handle files with a .php extension.
3 #
4 AddHandler php5-script .php
5 AddHandler php5-script .php5
6 AddType text/html .php, .php5, .html
7
8 #
9 # Add index.php to the list of files that will be served as directory
10 # indexes.
11 #
12 DirectoryIndex index.php index.php5

.php5 file extension had to be removed from line 4 and line 5 created just for it. Line 6 has to have the .php5 file extension in it, too. Line 12 had to be modified to include index.php5.

/etc/httpd/conf/httpd.conf had to remain modified in the way described in the start of this thread.

I hope this will help someone else, as well.