My previous articles on installing PHP on CentOS dealt with installing PHP 5.2.6. I have found this to have some bugs that kill the process without error information. One bug I found, which was on an x86_64 server, was that converting an object to a string did this.
So, I have compiled the latest PHP version, 5.2.10 5.3.0 5.3.2, and put it in my own repository for easy installation. I have compiled it for CentOS 5 i386 and x86_64, and provided the source RPMS in the repo, if anyone wants to compile it for another OS or architecture.
Update 2009-07-03 – I updated the version to PHP 5.3, which was released a few days before. This includes many new features such as closures, namespaces, and packaged scripts in phar files, which I’ll blog about soon. Check out PHP changelog for more details.
Update 2009-09-01 – Added a note about deprecated errors, and how to silence them. Also I have included a tip that might help those of you struggling to install.
Update 2010-03-03 – I’ve added both apc 3.1.3p1 beta (php-pecl-apc in yum) and eAccelerator 0.9.6 (php-eaccelerator in yum) RPMs to the repository, they are compiled for (and work on) php 5.3.x
I have also included the same php extensions I mentioned in my other article, php-mcrypt, php-mhash (in PHP 5.2), php-mssql and php-tidy
To install, first you must tell rpm to accept rpm’s signed by me, then add the yum repository information to yum:
rpm --import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo
Now you can install php by doing:
yum --enablerepo=webtatic install php
Or update an existing installation of php, which will also update all of the other php modules installed:
yum --enablerepo=webtatic update phpIf this does not work correctly, try disabling all other repositories while installing/updating, by adding the –disablerepo=* option. This will stop other dependencies from being installed, so you may want to install them first.
yum --disablerepo=* --enablerepo=webtatic update php
“Depsolving” problems
If you get depsolving problems when updating, you may have currently installed some extensions that have been removed, e.g. php-mhash, php-ncurses.
You will need to remove them before upgrading.
yum remove php-mhash php-ncurses
Deprecated Errors
Once you are running the new version, you may get “deprecated” errors in your error logs. This isn’t bad, it just means to tell you that some of the functions you are using are no longer prefered, and may be removed in a future major release. An example of this is the ereg functions. Preg functions are prefered over these, as they are much faster and more powerful, and in all cases do at least the same thing.
If upgrading the functions are not an option, and you would like to hide the deprecated errors from your error log, for example on a production server, just edit your /etc/php.ini file, find the line:
error_reporting = E_ALL
and replace to:
error_reporting = E_ALL & ~E_DEPRECATED
PHP 5.2.13
I am also maintaining a PHP 5.2.13 release, so should you prefer to install that (for reasons like incompatibilities or testing), you can force it to install that instead by doing:
yum --enablerepo=webtatic --exclude=php*5.3* update php
Or you can add to the /etc/yum.repos.d/webtatic.repo the line:
exclude=php*5.3*
please show me how I can remove them safely without deleting dependencies.
thank you.
A big Thank you!
I have saved a lot of time upgrading..
Best regards,
Raul
It’s work !
Thank you for your help guy!
Im a French webmaster and I use Linu Centos 5 with Plask 9.x
I just fix my problem with your help.
Note: Reboot a host after the update.
Hi, glad you found this helpful.
You don’t need to reboot the server, just restart httpd, by using:
service httpd restart
Having problems pulling in php-mysql:
Downloading Packages:
http://repo.webtatic.com/yum/centos/5/x86_64/php-pdo-5.2.12-1.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
http://repo.webtatic.com/yum/centos/5/x86_64/php-mysql-5.2.12-1.x86_64.rpm: [Errno 14] HTTP Error 404: Not Found
Hi, I emailed you earlier.
I’ve rebuilt the 64 bit RPMs (now version 5.2.12-1.1, the old ones deleted) after uninstalling all i386 packages, which will solve the previous problem.
You will probably need to run the command I mentioned for yum to refresh the repository metadata cache. “touch /etc/yum.repos.d/webtatic.com”
Hi Andy,
I get following errors
—-
http://repo.webtatic.com/yum/centos/11/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: webtatic. Please verify its path and try again
—–
Any help will be appreciated.
Sorry but I don’t have RPMs for your distribution (I’m assuming it’s Fedora 11 based on the resolved url?)
Fedora 12 does have PHP 5.3 though.
My main reason for this repo is because there is no other option for people who can’t switch from CentOS to another distribution, other than to compile PHP themselves.
Thank you very much. You have saved me a ton of time.
Worked like a charm
Thank you
hi! this works great however it appears php’s posix’s plugin is not available!
“POSIX functions are enabled by default. You can disable POSIX-like functions with –disable-posix.”
Did you disable them in your compile?
Hi Will,
The later releases of PHP packages for Red-Hat based distributions compile posix functions as a separate package (probably for reasons like shared hosting companies not wanting them in by default)
You can install the posix functions as part of the php-process package:
yum install --enablerepo=webtatic php-process
even tried the touch command
but couldn’t solve this …
please help in resolving this
[root@domU-12-31-39-06-BC-E2:/mnt/tmp] touch /etc/yum.repos.d/webtatic.com
[root@domU-12-31-39-06-BC-E2:/mnt/tmp] yum –enablerepo=webtatic update php
Loading “installonlyn” plugin
Setting up Update Process
Setting up repositories
http://repo.webtatic.com/yum/centos/5.0/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot open/read repomd.xml file for repository: webtatic
I already have installed php 5.2.11 but unfortunately it doesn’t support –enable-memcache
so jumping on php 5.2.12 or 5.3 but unable to install
I’ve not seen a CentOS distribution resolve $releasever to the minor release (x.y) before (in the webtatic.repo file), however I’ve now symlinked, on the server, 5 to 5.0-5.4 which should work in your configuration.
It seems like something got broken in the most recent updates to the repo. Running CentOS 5.4 and following the exact same steps that I have followed before, I received the following error message:
#yum –enablerepo=webtatic install php Loaded plugins: fastestmirror
…
–> Finished Dependency Resolution
php-mhash-5.2.12-1.1.x86_64 from webtatic has depsolving problems
–> Missing Dependency: php-common = 5.2.12-1.1 is needed by package php-mhash-5.2.12-1.1.x86_64 (webtatic)
…
mhash has been removed from the php library as they say hash has all that functionallity.
You need to remove the php-mhash package before updating.
I installed 5.3 on Centos 5.4 using your repo – thanks for all your work – it worked (almost) flawlessly.
The only problem I’ve seen so far is an error message when running a php cli script:
PHP Warning: PHP Startup: apc: Unable to initialize module
Module compiled with module API=20050922
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
Any suggestions?
@RoyHB I’ve now added apc to the repository, so if you upgrade that (php-pecl-apc), it will work. The error you were getting was because the currently installed apc was compiled for an older php