Wednesday, October 14, 2009

Update to current PHP on CentOS 5.3

The default version of PHP installed on CentOS 5.3 is 5.1.6. The command "yum update php" won't update to the current version. The function filter_var() is unavailable at 5.1.6, so this causes the undefined function error. Following steps will update to the current version of PHP to fix this problem.

1. Run following to check the PHP version and it should be 5.1.6:

php -v

2. Create /etc/yum.repos.d/utterramblings.repo to contain following information:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

3. Run following to update PHP as root:

yum update php

4. Run the following to confirm the update of PHP and currently it is 5.2.11:

php -v

5. Restart Apache server to pickup the new version of PHP.

/etc/init.d/httpd restart

6. The error "undefined function filter_var() ..." will be disappeared.

No comments: