How to upgrade from PHP4 to PHP5
A project that I was working on recently required the use of PHP5 XML Dom extension, but I still had PHP4 running on my Windows development box and I needed to upgrade it to PHP5. After battling with it for a couple of hours, I finally got it up and running.
Here is a list of important things you need to pay attention when upgrading from PHP4 to PHP5.
Assume your PHP installation directory is C:\PHP
#1: MySQL libraries are no longer bundled with PHP by default.
If you see the error "Call to undefined function mysql_connect()" when run a page that worked before but does not work now after upgrading to PHP5, you need to install MySQL libraries because MYSQL libraries are not installed automatically for you by PHP5. Instead, you'll need to manually install the MYSQL extension, just like you do with most every other extensions during the PHP5 setup process. MySQL is an item in the Extensions list and can be found in the step where you choose what items to install.
It's true for all other third-party libraries you used previously with PHP4, such as GD2, or Multi-Byte String. If you need them, choose from the Extensions list.
#2: Delete libmysql.dll and libmysqli.dll
This step is extremely important. You need to either remove them or rename these DLLs to something else. Otherwise, the old DLL will still be used and Apache will not be able to start and will cause memory address violation error because of conflicts between the old DLLs and the new DLLs. Below is the error:
Faulting application Apache.exe, version 0.0.0.0, faulting module php5ts.dll, version 188.8.131.52, fault address 0x000f34bc.
libmysql.dll (and/or libmysqli.dll) is MySQL client API DLL. Based on your system, you can find libmysql.dll and libmysqli.dll in various places. Typically, they are at:
#3: Delete other DLLs for the extensions that previously installed in C:\WINNT\system32.
When you previously installed PHP4, php_mysql.dll, php_mysqli.dll, php4ts.dll were put into C:/WINNT/system32, now delete them from there because with PHP5, they are now installed under a directory named as ext inside PHP installation directory.
#4: Delete old php.ini configuration file.
Delete your old php.ini file (make a backup copy so that you can roll back) from C:\WINNT, PHP5 should have created a new php.ini in your PHP installation directory.
#5: Modifications to the new php.ini
The new php.ini file is sitting inside C:\PHP folder. Make the following changes if needed.
(1) Change short_open_tag = Off to short_open_tag = On
This prevents your PHP code from being displayed in web browser if you only use tag but not (2) Turn off register_globals
register_globals = Off
(3) Add extension directory
extension_dir = "C:\PHP\ext"
(4) Add the following lines to the section called Dynamic Extensions
The extensions you selected in Step#1 will be added in automatically, but you'd better check it.
Other extensions will follow similar pattern if needed. eg.
#6: If you use Apache 1.3, modify its configuration file (httpd.conf) in order to use PHP5.
Comment out or remove:
LoadModule php4_module C:\php\sapi\php4apache.dll
LoadModule php5_module "C:/PHP/php5apache.dll"
#7: Add PHP initialization directory in Apache
Inside Apache configuration file httpd.conf, if PHPIniDir is not set to C:/PHP (I assume your PHP is installed at C:/PHP but it could be also C:/Program Files/PHP), do the following.
This will officially make C:/PHP/ to become the location for php.ini. This way, we group everything inside PHP installation directory for easy management.
#8: Finally, don't forget to restart Apache
To restart Apache, click Start button and go to Programs -> Administrative Tools -> Services, and find Apache in the service list and then restart it.
Copyright © 2017 GeeksEngine.com. All Rights Reserved.
This website is hosted by HostGator.
No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.