Custom Search
 


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.

Choose MySQL libraries to install with PHP5

#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 5.2.12.12, 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:

  • C:\WINNT\system32, or
  • C:\Program Files\MySQL\MySQL Server 5.0\lib\opt\libmysql.dll

#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 (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.

extension=php_mysql.dll
extension=php_mysqli.dll

Other extensions will follow similar pattern if needed. eg.

extension=php_gd2.dll
extension=php_mbstring.dll

#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
AddModule mod_php4.c

Add in:

LoadModule php5_module "C:/PHP/php5apache.dll"
AddModule mod_php5.c

#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.

Comment out:

PHPIniDir "C:/WINNT/"

Add in:

PHPIniDir "C:/PHP/"

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.

Happy installing!


Copyright© GeeksEngine.com



Other Recent Articles from the WAMP & LAMP category:

1.How to install MySQL Server 8 on Windows
2.How to resolve Apache web server port 80 access problem
3.The free tools I use to build PHP and MySQL websites
4.Steps to install PHP 5.x on Windows as a development machine
5.How to install Apache 2.x web server on Windows
6.How to connect two different versions of MySQL server on the same computer
7.How to configure MySQL server 5.1 on Windows
8.How to install MySQL server 5.1 on Windows with screenshots
9.How to load time zone data for MySQL on Windows
10.How to use Apache Virtual Host to run multiple local websites on Windows
11.Install all PEAR packages by yourself
12.How to install PEAR on Windows
13.How to use PHP and Microsoft SMTP Virtual Server to send emails
14.How to install PHP server-side scripting language on Windows
15.How to install Apache 1.3 web server on Windows
16.How to install two different versions of MySQL server on the same PC
17.How to configure MySQL server 4.1 on Windows
18.How to install MySQL server 4.1 on Windows with screenshots
19.How to set up DSN in ODBC Data Source Administrator on Windows

Copyright © 2024 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.

 
Home | Feedback | Terms of Use | Privacy Policy