Apache Recompiling with PHP4 to PHP5 Upgrade Problems

Sun, Nov 26, 2006

Server, Web

This is an on going post as you read this right now, I will edit it as I go on.

I have just upgraded my PHP4.4.1 to PHP5.2.0 on a cPanel server using the WHM Apache Update. So far I have encountered the following problems:

AddType .html extensions for PHP – error 500.

Problem: This does not work anymore if you have this line in your .htaccess file.

AddType application/x-httpd-php .php .php4 .php3 .phtml .html .htm

Solution: This will work. I looked at the httpd.conf file and checked how it was written in there.

AddHandler application/x-httpd-php .php .php4 .php3 .phtml .html .htm
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm

OK, The document has moved here.

Problem: I have PHP 301 Redirect pages, in fact I use it on this blog too. And instead of the page just directing. It shows an intermediate page that says:

OK
The document has moved here.

A message like this will really appear if there is some code before the PHP redirection code. And I had none since it was the first thing in my WordPress template, all the way on top.

Solution: In PHP5, it seems even having the header location code all the way on top, but is called by an include() or require() function, it will display the error message. So in my case where it was in a WordPress template, I took the code out and placed it on top of the main WordPress file. Disadvantage of this is, I will need to reinsert the code when a WordPress update comes out.

allow_url_include is disabled by default

If you have been using include() functions with actual absolute URLs with get include errors. And I have no plans on enabling it. They were disabled by default for security purposes. If you are having this problem with your scripts, instead of using:

include("http://www.domain.com/path/file.php");

Use this instead on a cPanel server:

include("/home/account_username/public_html/path/file.php");

ZenPhoto does not seem to work

Problem: getGalleryIndexURL(); function is not working. We are not sure why and there seems like no one has been writing about it yet in the ZenPhoto forums.

Solution: This function should output the URL of the photo gallery index. In templates it is usually used in album.php and image.php files for the breadcrumb navigation. Probably not the best solution but since it only occurs twice in our template, we just hard coded the link to the gallery index.

ForceType problems and other problems with Dew-Code phpLinks

Problem: A hosting client of mine using Dew-code phpLinks had problems of the script not working. And I have found not only 1 problem but several.

Problem with ForceType. The .htaccess file had this line:

ForceType application/x-httpd-php

Solution: Add SetHandler

SetHandler application/x-httpd-php
ForceType application/x-httpd-php

$_SERVER[PATH_INFO] not supported by default

Here is what the PHP Manual has to say:

cgi.fix_pathinfo: Provides real PATH_INFO/PATH_TRANSLATED support for CGI. PHP’s previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix it’s paths to conform to the spec. A setting of zero causes PHP to behave as before. Default is zero. You should fix your scripts to use SCRIPT_FILENAME rather than PATH_TRANSLATED.

Solution: I became a fan of the PATH_INFO sometime early 2005 and has been using it for some time. But since PHP recommends not to use it anymore, instead of globally enabling it, I am going to modify all scripts to be more compliant to the new way of doing things. But then again, I barely have the time to rewrite everything. And I will just come up with a patch to the problem. thus I am going to use:

$_SERVER[PATH_INFO] =
substr($_SERVER[REQUEST_URI], strlen($_SERVER[PHP_SELF]));

Ok now back to discovering more problems, so far, I still have the ZenPhoto problem.

UPDATE: Because of all these problems, I did a roll back to PHP4.4 and ran PHP5.2 on FastCGI and had Ruby on Rails enabled too. Thanks to Mike on his PHP4/PHP5/RoR setup.

Popularity: 2% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

This post was written by:

Benj Arriola - who has written 142 posts on action online.

Started a career as a chemist. Worked in the industry and academe and pursued a master's degree in chemistry. Then one day, here I go, start a computer shop, then web company in 1999, won a few awards and just started a web career working on websites of various companies and making sure the websites work for them.

Contact the author

Leave a Reply