Check PHP settings

WARNING
If you are using PHP 7.4.20, set pcre.jit=0 in your php.ini file. This gets around a PHP bug that prevents CSS from loading.
  • 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 the PHP memory limit.

    Adobe recommends the following:

    • Compiling code or deploying static assets, 1G
    • Debugging, 2G
    • Testing, ~3-4G
  • Increase the values for the PHP realpath_cache_size and realpath_cache_ttl to recommended settings:

    realpath_cache_size=10M
    realpath_cache_ttl=7200
    

    These settings allow PHP processes to cache paths to files instead of looking them up on page load. See Performance Tuning in the PHP documentation.

  • Enable opcache.save_comments, which is required for Adobe Commerce 2.1 and later.

    Adobe recommends enabling the PHP OPcache for performance reasons. The OPcache is enabled in many PHP distributions.

    Adobe Commerce 2.1 and later use PHP code comments for code generation.

NOTE
To avoid issues during installation and upgrade, Adobe strongly recommends that you apply the same PHP settings to both the PHP command-line configuration and the PHP web server plug-in configuration. For more information, see the next section.

Find PHP configuration files

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

Find php.ini configuration file

To find the web server configuration, run a phpinfo.php file in your web browser and look for the Loaded Configuration File as follows:

PHP info page

To locate the PHP command-line configuration, enter

php --ini | grep "Loaded Configuration File"
NOTE
If you have only one php.ini file, change that file. If you have two php.ini files, change both files. Failure to do so might cause unpredictable performance.

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 the php.ini file.

    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/php/8.1/fpm/php.ini

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

How to set PHP options

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

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

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

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

    For example,

    memory_limit=2G
    
  6. Add or update the realpath_cache configuration to match the following values:

    ;
    ; Increase realpath cache size
    ;
    realpath_cache_size = 10M
    
    ;
    ; Increase realpath cache ttl
    ;
    realpath_cache_ttl = 7200
    
  7. Save your changes and exit the text editor.

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

Set OPcache options

To set opcache.ini options:

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

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

  3. Make sure that 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