How to upgrade PHP to PHP 5.4 on CentOS 5

Created:

2016-11-16 13:06:06 UTC

Modified:

2017-04-24 11:01:17 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to upgrade PHP to PHP 5.4 on CentOS 5

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux

Upgrade from PHP 5.2 for Centos 5:

  1. Run Plesk autoinstaller from the server console:

    # /usr/local/psa/admin/sbin/autoinstaller
  2. On the main components list, ensure that the PHP5 support option is selected.

  3. Exit the autoinstaller

  4. Install Epel and Remi repositories:

    # wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

    # wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

    # sudo rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
  5. Enable the Remi repository:

    # sudo vi /etc/yum.repos.d/remi.repo

In the [remi] section of the file, set the " enabled " option to 1.

NOTE: to install PHP from the Atomic repository, use following command:

    # wget -q -O - http://www.atomicorp.com/installers/atomic | sudo sh
  1. Upgrade PHP:
    # yum install php

Upgrade from PHP 5.3

  1. Run Plesk autoinstaller from server console.

  2. On the main components list, ensure that the PHP 5.3 support option is selected

  3. Exit the autoinstaller

  4. Remove all PHP 5.3 components and the PHP 5.3 configurator

To check which packages will be removed, use the following command:

    # rpm -qa | grep 'php53-'

All the listed packages will be removed with the following commands:

    # rpm -e --nodeps `rpm -qa | grep psa-php53-configurator-`

# rpm -e `rpm -qa | grep 'php53-' | xargs`
  1. Run Autoinstaller from the server console

  2. Check and install PHP5 support option

  3. Install the Epel and Remi repositories:

    # wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

    # wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

    # sudo rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
  4. Enable the Remi repository:

    # sudo vi /etc/yum.repos.d/remi.repo

In the [remi] section of the file, set the " enabled " option to 1.

NOTE: to install PHP from the Atomic repository, install it with the following command:

    # wget -q -O - http://www.atomicorp.com/installers/atomic | sudo sh
  1. Upgrade PHP:
    # yum install php

Installing ionCube for PHP 5.4 (optional):

  1. Download ionCube:

For x32:

    # wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.zip

For x64:

    # wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.zip
  1. Unzip the file.

  2. Copy ioncube_loader_lin_5.4.so to the PHP extensions directory:

    #sudo cp ioncube/ioncube_loader_lin_5.4.so /usr/lib/php/modules/

Please note that the actual extensions directory ( /usr/lib/php/modules/ ), where PHP modules are located, may vary. Check the location using the php -ini command:

    php -ini|grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
  1. Set SELinux attributes:

    # sudo chcon -u system_u  -t lib_t /usr/lib/php/modules/ioncube_loader_lin_5.4.so

    # ls -Z /usr/lib64/php/modules/ioncube_loader_lin_5.4.so
    -rw-r--r--. root root system_u:object_r:lib_t:s0 /usr/lib64/php/modules/ioncube_loader_lin_5.4.so
  2. Switch on ionCube in the PHP config:

    # echo "zend_extension=/usr/lib/php/modules/ioncube_loader_lin_5.4.so" >> /etc/php.d/zend_extensions_psa.ini
  3. Ensure that ionCube is working:

    # php -r 'phpinfo();' | grep -i ioncube

It is possible to test the ionCube Loader using the helper PHP loader-wizard.php script, which is included to the ionCube Loader archive.

Possible Issues

  1. MySQL server is upgraded with PHP. If the process fails with MySQL errors such as " Table mysql.servers does not exist " when creating databases, database users, or applications, then the MySQL server has been upgraded with PHP. This can be fixed using the following command:

    # mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow`
  2. If an error message is shown:

    Failed loading /usr/lib/php/modules/ioncube_loader_lin_5.4.so: /usr/lib/php/modules/ioncube_loader_lin_5.4.so: wrong ELF class: ELFCLASS6`

it means that the architecture of the ionCube Loader file is for the different operating system architecture.

  1. If an error message is shown:
    Failed loading /usr/lib/php/modules/ioncube_loader_lin_5.4.so:  /usr/lib/php/modules/ioncube_loader_lin_5.4.so: wrong ELF class: ELFCLASS6`""`Failed loading /usr/lib/php/modules/ioncube_loader_lin_5.4.so:  /usr/lib/php/modules/ioncube_loader_lin_5.4.so: cannot restore segment prot after reloc: Permission denied`

it means SELinux is effective. Incorrect SELinux context is set on the ionCube Loader file.

  1. PHP does not work in CGI/FastCGI mode with HTTP Error 500. This can be caused by directives that are incompatible with PHP 5.4 in the global or domain php.ini file. Here is a list of incompatible directives:
    register_globals
    register_long_arrays
    magic_quotes_gpc
    magic_quotes_runtime
    magic_quotes_sybase
    allow_call_time_pass_reference
    define_syslog_variables
    highlight.bg
    session.bug_compat_42
    session.bug_compat_warn
    y2k_compliance
    safe_mode
    safe_mode_gid
    safe_mode_include_dir
    safe_mode_exec_dir
    safe_mode_allowed_env_vars
    safe_mode_protected_env_vars
    zend.ze1_compatibility_mode`

See http://www.php.net/manual/en/migration54.ini.php for details.

Have more questions? Submit a request
Please sign in to leave a comment.