Skip to content

Latest commit

 

History

History
145 lines (94 loc) · 6.09 KB

php-settings.md

File metadata and controls

145 lines (94 loc) · 6.09 KB
group subgroup title menu_title menu_order level3_menu_node level3_subgroup functional_areas
installation-guide
Prerequisites
Required PHP settings
Required PHP settings
24
level3child
php
Install
System
Setup

This topic discusses how to set required {% glossarytooltip bf703ab1-ca4b-48f9-b2b7-16a81fd46e02 %}PHP{% endglossarytooltip %} options.

{% collapsible About required and recommended PHP options: %}

  • 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]
    
  • Set always_populate_raw_post_data = -1{:target="_blank"}

    always_populate_raw_post_data is deprecated in PHP 5.6 and is dropped in PHP 7.0.x. This setting causes PHP to always populate $HTTP_RAW_POST_DATA with raw POST data. Failure to set this properly in PHP 5.5 or 5.6 results in errors when connecting to the database.

  • Set the PHP memory limit.

    Our detailed recommendations are:

    • Compiling code or deploying static assets, 756M
    • Installing and updating Magento components from Magento Marketplace, 2G
    • Testing, 2G
  • Disable asp_tags{:target="_blank"}

    If asp_tags are enabled, errors display when accessing PHTML templates.

    asp_tags will be removed in PHP 7.

  • Enable opcache.save_comments{:target="_blank"}, which is required for Magento 2.1 and later.

    We recommend you enable the PHP OpCache{:target="_blank"} for performance reasons. The OPcache is enabled in many PHP distributions.

    Magento 2.1 and later use PHP code comments in the getDocComment validation call in the [getExtensionAttributes]({{ site.mage2100url }}lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php#L64-L73){:target="_blank"} method in Magento\Framework\Api\ExtensionAttributesFactory.php.

{: .bs-callout .bs-callout-warning } To avoid issues during installation and upgrade, we strongly recommend you apply the same PHP settings to both the PHP command-line configuration and to the PHP web server plug-in's configuration. For more information, see the next section.

{% endcollapsible %}

Step 1: Find PHP configuration files {#php-required-find}

This section discusses how you find the configuration files necessary to update required settings.

{% collapsible To find the PHP configuration file, php.ini: %} To find the web server configuration, run a [phpinfo.php file]({{ page.baseurl }}/install-gde/prereq/optional.html#install-optional-phpinfo) in your web browser and look for the Loaded Configuration File as follows:

![]({{ site.baseurl }}/common/images/config_phpini-webserver.png){: width="700px"}

To locate the PHP command-line configuration, enter

php --ini

Use the value of Loaded Configuration file.

{: .bs-callout .bs-callout-warning } If you have only one php.ini file, make the changes in that file. If you have two php.ini files, make the changes in all files. Failure to do so might cause unpredictable performance.

{% endcollapsible %}

{% collapsible To find OPcache configuration settings: %}

PHP OPcache settings are typically located either in php.ini or opcache.ini. The location might depend on your operating system and PHP version. The OPcache configuration file might have an [opcache] section or settings like opcache.enable.

Use the following guidelines to find it:

  • Apache web server:

    For Ubuntu with Apache, OPcache settings are typically located in php.ini.

    For CentOS with Apache or nginx, OPcache settings are typically located in /etc/php.d/opcache.ini

    If not, use the following command to locate it:

    sudo find / -name 'opcache.ini'
    
  • nginx web server with PHP-FPM: /etc/php5/fpm/php.ini

If you have more than one opcache.ini, modify all of them.

{% endcollapsible %}

Step 2: How to set PHP options {#php-required-set}

{% collapsible To set PHP options: %}

  1. Open a php.ini in a text editor.

  2. Locate your server's time zone in the available time zone settings{:target="_blank"}

  3. Locate the following setting and uncomment it if necessary:

    date.timezone =
    
  4. Add the time zone setting you found in step 2.

  5. Change the value of memory_limit to one of the values at the beginning of this section.

    For example,

    memory_limit=2G
    
  6. 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
    
  7. Locate the following setting:

    asp_tags =
    
  8. Make sure its value is set to Off.

  9. Save your changes and exit the text editor.

  10. Open the other php.ini (if they are different) and make the same changes in it.

{% endcollapsible %}

Step 3: Set OPcache options {#php-required-opcache}

{% collapsible To set opcache.ini options: %}

  1. Open your OpCache configuration file in a text editor:

    • opcache.ini (CentOS)
    • php.ini (Ubuntu)
    • /etc/php5/fpm/php.ini (nginx web server (CentOS or Ubuntu))
  2. Locate opcache.save_comments and uncomment it if necessary.

  3. Make sure its value is set to 1.

  4. Save your changes and exit the text editor.

  5. Restart your web server:

    • Apache, Ubuntu: service apache2 restart
    • Apache, CentOS: service httpd restart
    • nginx, Ubuntu and CentOS: service nginx restart

{% endcollapsible %}

Related topics

  • [MySQL]({{ page.baseurl }}/install-gde/prereq/mysql.html)
  • [Apache]({{ page.baseurl }}/install-gde/prereq/apache.html)
  • [PHP 5.5, 5.6, or 7.0—CentOS]({{ page.baseurl }}/install-gde/prereq/php-centos.html)
  • [Configuring security options]({{ page.baseurl }}/install-gde/prereq/security.html)
  • [Installing optional software]({{ page.baseurl }}/install-gde/prereq/optional.html)
  • [How to get the Magento software]({{ page.baseurl }}/install-gde/bk-install-guide.html)