Published August 30th, 2005 by Jim O'Halloran
PHP 5 for CentOS 4.1
One nice thing about CentOS is the long support life and stability of the system. One not so nice thing is that because it is based on Red Hat Enterprise, the package selection is pretty conservative. That’s not too bad though, Apache is 2.0.52, MySQL is a 4.0.x version, so things are reasonably current. One thing that’s really dated though is PHP (4.3.x)… I’ve been using PHP 5 for a while and quite like it, so a PHP 5 package for CentOS would be nice. Good news though is that one already exists, its in the CentOSPlus repository. This post to the CentOS Mailing List explains what the CentOSPlus repo is for.
To enable CentOSPlus edit /etc/yum.repos.d/CentOS-Base.repo. After [centosplus] heading, you’ll see a line that currently says “enabled=0″. Change that to “enabled=1″ to enable CentOSPlus. Once the CentOSPlus repo is enabled, “yum update” will search the repository and offer to upgrade any packages to newer versions from CentOSPlus. If you had PHP installed previously, this will upgrade you to PHP 5.0.x.
Dominic Says
Hello,
I did this but it updated everything with the exception of PHP which is what I wanted!. Any ideas?
Jan 13th, 2006 at 12:01 pm
James Says
Just what the doctor ordered. Thanks so much, Jim.
jas
Jan 22nd, 2006 at 10:57 am
Doug Says
Thanks Jim. This post was most helpful.
Apr 11th, 2006 at 7:24 am
Doug Says
Dominc,
Check this out.
http://www.vinnia.se/2006/03/20/running-php5-on-tao-linux/
Apr 11th, 2006 at 7:34 am
Steven Says
Perfect simple step - thanks tons!
May 5th, 2006 at 9:47 am
Hudson Says
Thank you very much for your help!
May 19th, 2006 at 1:50 am
Phil Says
Aha! Great. Thanks very much
Jun 7th, 2006 at 7:22 am
Artur Says
Most excellent
will try this in the morning. Trying to find rpms for php5 for centos3 but I guess no such animal exists.
Jun 29th, 2006 at 2:55 pm
Tachou Says
Thanks alot, you save the night !
Jul 3rd, 2006 at 1:56 pm
Mark Says
I can’t believe it. I’ve wasted hours trying to get php5 to compile and your little tip fixed it in seconds. Thanks!
Jul 27th, 2006 at 10:12 pm
Mark Says
Oops! Spoke to soon.
This version lacks some important features which I need, such as pgsql support. Had to uninstall it and re-install the older version. Any ideas?
Jul 29th, 2006 at 11:28 am
jim Says
pgsql support is usually packaged separately, try a “yum install
php-pgsql”.
Jim.
Jul 29th, 2006 at 12:53 pm
jim Says
Got this reply in email from Mark…
—– Cut Here ——
Thanks for your reply, Jim
Tried that, but pgsql still won’t work, and phpinfo() indicates that php was configured without pgsql. Is there a way of retrofitting a confiure options?
Thanks,
Mark
—– Cut Here ——
Just checked the mirror I used and there’s definately a php-pgsql rpm in the centos plus repository… So a few things you might want to check…
1) The once you’ve got php 5 and the php-pgsql package installed, check the “extension_dir” setting in php.ini, make sure the directory exists and the pgsql.so file is in that directory. Mine is set to “/usr/lib/php/modules”, so that’s where the .so files will be installed by default. If yours isn’t set to that directory then it might be easier to change the extension_dir rather than move the .so’s.
2) Make sure the line “extension=pgsql.so” appears somewhere either in php.ini or one of the /etc/php.d/*.ini files. This will force PHP to load the pgsql extension.
I’m not sure how phpinfo() determines the configure command line, whether the exaual command line is compiled into PHP itself when its built, or whether it’s just reconstructed when the phpinfo() page is generated based on the extensions that are currently loaded. Either way, the presence of a pgsql section in the phpinfo output is probably the most reliable indicator of whether the extension is loaded or not.
Jim.
Jul 30th, 2006 at 11:09 am
jim Says
Another worthwhile thing to do would be to check the syslog or /var/log/php.log to see if there’s any error messages indicating problems loading the pgsql extension. They might give you a pointer as to where to look next.
Jim.
Jul 30th, 2006 at 11:12 am
Raul Says
I’ve known about the CentOSPlus repository for a while (http://mirror.centos.org/centos/4.3/centosplus/x86_64/RPMS/), but have always downloaded and installed the RPM’s by hand. This is so much more convienient since YUM will usually handles all the dependencies.
Great stuff.
Aug 19th, 2006 at 2:34 am
Piers Says
Great posting, very helpful.
Aug 26th, 2006 at 7:23 am
Craig Says
hell yeah, worked like a charm!
Thanks!!!
Aug 30th, 2006 at 10:12 am
Jonee Ryan Ty Says
actually you just have to enable the repo and as root do a
yum upgrade php
instead of updating your whole system
Sep 6th, 2006 at 6:13 pm
Jason Says
Great tip! Thanks a bunch…Just saved me all sorts of pain!
Nov 17th, 2006 at 3:33 am
Boyce Says
This worked for me, but I use the protect and fastest mirror plugins and didn’t want to upgrade packages other than php5 so I made a slight change suggested by the article linked to in Jim’s post. I have the CentOSPlus already enabled already but the Base and Updates repositories protected. I didn’t want to change that so I used the “exclude=php*” directive on each and then did a “yum checkupdate php” and found it available. Its installed now and working like a charm. Thanks!
Nov 25th, 2006 at 3:04 pm
Mark Crosby Says
I just want to say thank you so much for this!!
Dec 1st, 2006 at 11:21 am
AMing Says
I wait php5 so long. It is helpful for me. Thank you very much
Dec 3rd, 2006 at 6:22 pm
Pau Says
Awesome! Thanks!
Jan 24th, 2007 at 1:06 am
Peter Stubbs Says
If you are using Blue Quartz GUI do not install this as it will break it.
Apr 18th, 2007 at 1:23 am
Nitesh Says
Awesome! Thanks man! It worked like a blink of an eye…
May 18th, 2007 at 11:54 pm
mike Says
Whoa you saved me at least an hour! Hooray for google
May 22nd, 2007 at 5:59 am
Johnson Chen Says
This is very neat! Save me a bundle of headache. Thank you!
Jun 20th, 2007 at 4:28 am
acito Says
I faced some problem when i update to php 5..
look into phpinfo()
Configure Command
‘./configure’ ‘–without-pear’ ‘–without-mysql’ ‘–without-gd’ ‘–without-odbc’ ‘–disable-dom’ ‘–disable-dba’ ‘–without-unixODBC’ ‘–disable-pdo’ ‘–disable-xmlreader’ ‘–disable-xmlwriter’
which PEAR and MySql is needed..
after update.. my application indicate this error:
PHP PEAR must be installed. Visit http://pear.php.net for help with installation.
i have install Pear and located under /usr/share/pear
any help might be useful
thanks in advance.
Jul 5th, 2007 at 7:38 pm
www.gamebeat.net Says
Thanks a bunch, just what I needed!
Jul 11th, 2007 at 1:06 am
Wil Says
Hey there… I did this and it went off just fine thanks. php-xml was not installed so first I had to do a yum install php-xml but after that it was all gravy.
When I look at phpinfo()’s results however it still says PHP Version 4.3.9
When I run php –version from the shell I see PHP 5.1.6
WTF?
Aug 9th, 2007 at 6:42 am
jim Says
If you haven’t already, you’ll need to restart Apache to force it to reload the PHP modules. Typing “service httpd restart” at a command line is the easiest way to do it.
Jim.
Aug 9th, 2007 at 9:07 am
Roshan Kulkarni Says
I had a difficult time getting PHP 5 to work with MySQL on CentOS Release 5. phpinfo() indicated that the PHP configuration had the –without-mysql option. Also, there was no mysql section in the output of phpinfo().
Here is what finally made it work:
* Do a ‘yum install php-mysql’
* Check /etc/php.ini to determine the extension_dir where php modules are located. It was ‘/usr/lib/php/modules’ on my machine.
* Check if mysql.so was present in the modules directory.
* Add a ‘extension=mysql.so’ entry in php.ini
That’s it. MySQL works from PHP now. phpinfo() still shows that the configuration is –without-mysql. However there is now a mysql section in the output of phpinfo().
Hope this helps.
-Roshan
http://www.it.iitb.ac.in/~roshan
Oct 3rd, 2007 at 9:34 pm
John Says
Your advice was a great start for me, as I’m probably in way over my head- but certainly trying to learn. I enabled centosplus and tried to update the entire system with yum via webmin, but the upgrade failed without giving any context. So then I thought I should try a smaller step by just updating php. Any idea why I’m getting this missing dependency? What steps would you take from here? Any help would be greatly appreciated. Thank You, John
# yum upgrade php
Setting up Upgrade Process
Setting up repositories
Reading repository metadata in from local files
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Package php.x86_64 0:5.1.6-3.el4s1.8 set to be updated
–> Running transaction check
–> Processing Dependency: php = 4.3.9-3.22.9 for package: php-mysql
–> Processing Dependency: php-cli = 5.1.6-3.el4s1.8 for package: php
–> Processing Dependency: php = 4.3.9-3.22.9 for package: php-pear
–> Processing Dependency: php-common = 5.1.6-3.el4s1.8 for package: php
–> Restarting Dependency Resolution with new changes.
–> Populating transaction set with selected packages. Please wait.
—> Package php-common.x86_64 0:5.1.6-3.el4s1.8 set to be updated
—> Package php-mysql.x86_64 0:5.1.6-3.el4s1.8 set to be updated
—> Package php-cli.x86_64 0:5.1.6-3.el4s1.8 set to be updated
–> Running transaction check
–> Processing Dependency: php-pdo for package: php-mysql
–> Processing Dependency: libmysqlclient.so.15()(64bit) for package: php-mysql
–> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: php-mysql
–> Processing Dependency: php = 4.3.9-3.22.9 for package: php-pear
–> Restarting Dependency Resolution with new changes.
–> Populating transaction set with selected packages. Please wait.
—> Package php-pdo.x86_64 0:5.1.6-3.el4s1.8 set to be updated
—> Package mysql-libs.x86_64 0:5.0.48-1.el4.centos set to be updated
–> Running transaction check
–> Processing Dependency: php = 4.3.9-3.22.9 for package: php-pear
–> Finished Dependency Resolution
Error: Missing Dependency: php = 4.3.9-3.22.9 is needed by package php-pear
Dec 19th, 2007 at 11:14 am
Ollie Says
You saved my bacon as I need to use PHP 5 for the Zend Framework. Thanks a ton.
Jan 16th, 2008 at 7:31 pm
Matthew Says
Thanks a bundle! I was going to download a MySQL 3rd-party RPM but this saved me a few dozen megabytes!
Thanks!
Oct 7th, 2008 at 7:45 am