View Full Version : Can't parse PHP5 files
MarmaladeMan
12-11-2006, 02:13 PM
Hi,
I've followed the Resource Center article (http://apisnetworks.com/resources.php?cid=5&id=11) on how to run PHP5, but my files with .php5 extensions aren't being parsed. I have this in my .htaccess in my root /var/www/html directory:
RewriteEngine On
RewriteCond %{HTTP_HOST} !(www\.)?php\.
RewriteCond %{SCRIPT_FILENAME} \.php5$
RewriteCond %{SERVER_NAME} (www\.)?(.+)
RewriteRule ^(.*)$ http://www.php.%2:9000/$1 [P,L]
The particular file I'm trying to run is not in the root directory (it's in a subdirectory), if that's at all significant. When I browse to it, I see the code of the actual file displayed as text. I tried putting a separate, identical .htaccess file in the same directory, but when I do that I get a 404 error on the php5 file (as an aside, is something like that even necessary, or is one .htaccess file in the main document root all you need?).
Sorry if this is a new user mistake, any help is appreciated! Thank you.
Whenever you receive an error from the Web server, check /var/log/httpd/error_log for more information. So long as the permissions permit the Web server to read it (0644), then it should be fine. Move the .htaccess to the subdirectory under /var/www/html/ and change the rewrite rule directive to RewriteRule ^(.*)$ http://www.php.%2:9000/<directory>/$1 [P,L]
MarmaladeMan
12-11-2006, 05:05 PM
This is interesting. I checked the logs and there are no errors. File permissions are 644. I did what you suggested with the .htaccess file and it still gave me the 404 error.
It didn't occur to me to mention this (sorry for that), but I was accessing the directory through a subdomain (dev.hiprmod.net, which goes to /var/www/html/dev). When I linked to www.hiprmod.net/dev/other_subfolders, it worked.
Is that expected? Does that have to do with the RewriteRule path defined in the .htaccess file (it wouldn't recognize the subdomain?)?
Thanks again for the help! Seems to work fine now.
edit
The subdomain seems to be messing with it. Here's the .htaccess file I have (the file itself is in the /dev/wiki directory):
RewriteEngine On
RewriteCond %{HTTP_HOST} !(www\.)?php\.
RewriteCond %{SCRIPT_FILENAME} \.php$
RewriteCond %{SERVER_NAME} (www\.)?(.+)
RewriteRule ^(.*)$ http://www.php.%2:9000/dev/wiki/$1 [P,L]
I changed the third line to RewriteCond %{SCRIPT_FILENAME} \.php$, and added the subdirectories to the RewriteRule line.
If I go to www.hiprmod.net/dev/wiki/index.php, I see the page fine (though the URL shows up in Firefox as http://www.php.hiprmod.net:9000/dev/wiki/index.php/Main_Page). If I go to dev.hiprmod.net/wiki/index.php, I get a 404 that says The requested URL /dev/wiki/index.php was not found on this server.
It's funny, if I go to www.hiprmod.net/dev/wiki or dev.hiprmod.net/wiki (no specification of /index.php), I get a PHP syntax error.
Since you're using MediaWiki, let's see
RewriteEngine On
RewriteCond %{HTTP_HOST} !(www\.)?php\.
RewriteCond %{SCRIPT_FILENAME} \.php$
RewriteCond %{SERVER_NAME} (www\.)?(.+)
RewriteRule ^(.*)$ http://www.php.hiprmod.net:9000/dev/wiki/$1 [P,L]
And set $wgServer to http://dev.hiprmod.net/ in LocalSettings.php. That *should* do it. If not I'll take a look at it in the morning after I hammer out a bit of the Postfix conversion scripts. I'm changing the PHP5 rewrite around a bit in the fourth gen too. Dropping the www.php so it'll be a straight shot from http://a.com/ to http://a.com:9000/ for PHP5 functionality. Thus the only rewrite condition is to check if the port is 9000 or not.
MarmaladeMan
12-12-2006, 02:54 AM
Excellent! The only other thing I had to change was the $wgScriptPath setting in LocalSettings.php (changed it from /dev/wiki to just /wiki). I also remembered that I needed to add the additional RewriteCond to .htaccess to handle when there is no exact filename specified.
Now it works when I go to dev.hiprmod.net/wiki. Thank you!
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.