Close [x]

PHP 5.5 or 5.6—CentOS

Edit this page on GitHub

Contents

If you must install both Apache and PHP, install Apache first.

PHP versions supported

Magento requires:

  • PHP 5.5.x
  • PHP 5.6.x

Magento no longer supports PHP 5.4.

Help if you're just starting out

If you鈥檙e new to all this and need some help getting started, we suggest the following:

Verify PHP is installed

To verify if PHP is installed already, enter php -v. If PHP is installed, messages similar to the following display:

PHP 5.6.4 (cli) (built: Dec 20 2014 17:30:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

If PHP is installed, continue with the next prerequisite, MySQL.

If PHP is not installed, see one of the following sections:

PHP 5.6 on CentOS

There is more than one way to upgrade CentOS 6.5 to PHP 5.6; the following is a suggestion only. Consult a reference for additional options.

To upgrade to PHP 5.6:

  1. Enter the following commands in the order shown:

    rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
    yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring php56w-bcmath
    

    The bcmath extension is required for Magento Enterprise Edition (EE) only.

  2. Restart Apache: service httpd restart

  3. Enter the following command to verify that PHP 5.6 is installed:

    php -v
    

    The following response indicates that PHP 5.6 is installed properly:

    PHP 5.6.4 (cli) (built: Dec 20 2014 17:30:46)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    

The preceding message confirms that the Zend OPcache is installed. We strongly recommend using the OPcache for performance reasons. If your PHP distribution does not come with the OPcache, see the PHP OPcache documentation.

  1. Set up PHP configuration options.

PHP 5.5 on CentOS

There is more than one way to upgrade CentOS 6.5 to PHP 5.5; the following is a suggestion only. Consult a reference for additional options.

To upgrade to PHP 5.5:

  1. Enter the following commands in the order shown.

    yum -y update
    rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
    yum -y remove php-common-5.3.3-40.el6_6.x86_64
    yum -y install php55w php55w-opcache
    yum -y install php55w-xml php55w-mcrypt php55w-gd php55w-devel php55w-mysql php55w-intl php55w-mbstring php55w-bcmath
    yum -y update
    

    The bcmath extension is required for Magento Enterprise Edition (EE) only.

  2. Restart Apache: service httpd restart

  3. Continue with the next section.

Set PHP configuration options

This section discusses how to:

  • Set the system time zone for PHP; otherwise, errors like the following display during the installation and time-related operations like cron might not work:
    PHP Warning:  date(): It is not safe to rely on the system's timezone settings. [more messages follow]
  • Increase the PHP memory limit to at least 768MB for normal operation or 2GB for testing.
  • Set always_populate_raw_post_data = -1
    always_populate_raw_post_data is deprecated in PHP 5.6. This setting causes PHP to always populate $HTTP_RAW_POST_DATA with raw POST data. Failure to set this properly in PHP 5.6 results in errors when connecting to the database.
  • Disable asp_tags. If asp_tags are enabled, errors display when accessing PHTML templates.
    asp_tags will be removed in PHP 7.

To set PHP options:

  1. Locate php.ini by entering the following command:
    php -i | grep "Loaded Configuration File"
    Typical locations follow:

    Ubuntu: /etc/php5/cli/php.ini
    CentOS: /etc/php.ini
  2. Open php.ini in a text editor.
  3. Locate your server's time zone in the available time zone settings.
  4. Locate the following setting and uncomment it if necessary:
    date.timezone =
  5. Add the time zone setting you found in step 1.
  6. Change memory_limit to:

    memory_limit = 768M or more for normal operation
    memory_limit = 2G or more for testing
  7. Required for PHP 5.6, recommended for PHP 5.5. Locate always_populate_raw_post_data, uncomment it if necessary, and set it as follows:
    always_populate_raw_post_data = -1
  8. Locate the following setting:
    asp_tags =
  9. Make sure its value is set to Off
  10. Save your changes and exit the text editor.
  11. Restart Apache:

    Ubuntu: service apache2 restart
    CentOS: service httpd restart

Optional: Configure caching alternatives

You can optionally specify alternatives to file system caching in php.ini by modifying the value of session.save_handler. Magento supports the following values:

  • files (the default) for file system caching
  • db for database caching
  • redis for Redis caching
  • Any other custom cache type you set up; however, it's up to you to know how to specify it in php.ini