How to Upgrade PHP

Posted by Nessa | Posted in ,, | Posted on December 4, 2007

5

Whether you compiled manually or with EasyApache, running a PHP upgrade from a previous version is super easy but also one of the most common questions I get. There are 3 likely assumptions about your current environment (specific to Linux servers, sorry Windows users):

1. You are running a cPanel server and have PHP compiled by EasyApache

2. You compiled PHP manually from source

3. You used Yum, Aptitude, or another package manager

EasyApache

Perhaps the easiest (but least efficient time-wise), simply log into WebHost Manager > Apache Update and select “Previously Saved Config” option and “Start Customizing Based on Profile“. The next screen should take you to the Apache version, which you can keep the same or upgrade as well. Then you’ll be taken to select either PHP 4 or PHP 5, proceeded by the actual version you wish to run and then the options for both Apache and PHP on the next two steps (Advanced Configuration). You usually do not need to change the options if your target is just a simple upgrade within the same version family, but if you changed the Apache version, updated cPanel recently, or are upgrading to a different PHP version family (like 4.4.7 to 5.2.x), then you’ll want to double-check the Apache/PHP build options to make sure they are what they need to be before selecting “Save and Build.” If you are running older versions of EasyApache (usually with cPanel 10 or early versions of cPanel 11 STABLE) then all you have to do is select ‘Load Previous Config‘, pick your PHP version, and ‘Build‘.

Source

If you’ve compiled PHP from source (./configure && make && make install method), you can use your previous configure arguments to compile against a different version. Refer to your server’s phpinfo file (if you don’t have one just create a PHP script with <?php phpinfo(); ?>) and copy the entire ./configure statement into notepad and remove the single quotes. Once you’ve done this, download the source tarball of the new PHP version, untar, and then enter the installation directory. From there, all you have to do is paste the configure statement from notepad. For instance, for PHP 5.2.5:

wget http://www.php.net/get/php-5.2.5.tar.gz/from/this/mirror

tar -xvzf php-5.2.5.tar.gz

cd php 5.2.5

./configure –options-from-your-phpinfo

After the configuration is complete, the script may indicate at the end of its output that you’ve specified configuration options that do not exist. This usually will not affect your build, but you’ll want to review them and consult the PHP documentation on the correct syntax or alternatives to the invalid build options, as these can change depending on which version of PHP you are installing. Doing a ./configure –help will also display the valid options you can use.

Once you have a good configuration, you can go ahead with the make and make install to install the new version of PHP. If you have PHP integrated with Apache (usually you would unless you compiled as CGI) then the installation should have already updated the PHP binary for Apache and module loader in httpd.conf. However, you may need to manually comment out old module loaders if there are conflicts. You’re looking for something like this:

LoadModule php5_module        modules/libphp5.so

Package Installation

Some people have PHP installed via package manager, like Yum or Aptitude. Since the package software usually handles all aspects of the configuration and installation (outside of modules you may have installed via PEAR or Pecl), then you can use its update function to take care of the upgrade as well. Most have a specific option for upgrades, for instance Yum uses:

yum update php

For more information, see NixCraft’s article on PHP installations with Yum.

Share and Enjoy:
  • Digg
  • DZone
  • del.icio.us
  • Technorati
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Twitter
  • Sphinn
  • Mixx
  • blogmarks
  • Furl
  • Reddit
  • Slashdot
  • RSS

Related posts:

  1. Massive Upgrade Time
  2. The [pretty much] Complete Guide to Installing ffMPEG and Audio Binaries
  3. Moving Towards PCI Compliance with cPanel
  4. How to Install PHP6
  5. Installing suPHP on cPanel

Comments (5)

I always compile my own PHP, its really the optimal way to do it, because you can specify exactly what you need it to do. Of course, this also typically involves a bucket full of dependencies that need to be installed before configure is successful, but I feel better about it anyway.

Then, of course, it’s best to create a “dummy package” for your servers’ package manager so that it doesnt try to download it for any packages that might require that.

For rpm: create a file named /usr/src/packages/SPECS/php-dummy.spec

and fill it with:
Name: php
Version: 5.2.5
Release: 0
License: GPL
Group: System
Requires: requirements
Provides: php
Buildarch: noarch
Summary: A virtual package to fulfil dependencies
%description
This package is just a dummy package to satisfy RPM dependencies that actually
are fulfilled.
%files

then build the dummy package with:
rpm -ba
/usr/src/packages/SPECS/php-dummy.spec

this results in a package at
/usr/src/packages/RPMS/noarch/php-dummy-5.2.5-0.noarch.rpm

for debian:
apt-get install equivs

them we create the file php.ctl:

Section: web
Package: php-dummy
Provides: php
Description: PHP dummy package
This package provides dpkg with the information that php is installed.

then create the package:
equivs-build php.ctl

and then install it with apt.

[...] 4th 2007 5:21pm [-] From: v-nessa.net [...]

[...] v-nessa.net » Post Archive » How to Upgrade PHP Información sobre como actualizar PHP desde WHM y de manera manual. (En inglés) (tags: php upgrade yum whm) Compartir: [...]

[...] How to Upgrade PHP: Información sobre como actualizar PHP desde WHM y de manera manual. (En inglés) [...]

Post a comment