This topic discusses how to set required PHP options.
See system requirements for supported versions of PHP.
Most flavors of Linux have PHP installed by default. This topic assumes that you have already installed PHP. To verify if PHP is installed already, in the command line, type:
php -v
If PHP is installed, a message similar to the following displays:
PHP 7.4.0 (cli) (built: Aug 14 2019 16:42:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.6, Copyright (c) 1999-2018, by Zend Technologies
Adobe Commerce and Magento Open Source 2.4 is compatible with PHP 7.3, but we test with, and recommend using, PHP 7.4.
If PHP is not installed, or a version upgrade is needed, install it following instructions for your particular Linux flavor.
On CentOS, additional steps may be required.
Adobe Commerce and Magento Open Source requires a set of extensions to be installed.
Adobe Commerce requires:
ext-bcmath
ext-ctype
ext-curl
ext-dom
ext-fileinfo
ext-filter
ext-gd
ext-hash
ext-iconv
ext-intl
ext-json
ext-libxml
ext-mbstring
ext-openssl
ext-pcre
ext-pdo_mysql
ext-simplexml
ext-soap
ext-sockets
ext-sodium
ext-spl
ext-tokenizer
ext-xmlwriter
ext-xsl
ext-zip
ext-zlib
lib-libxml
B2B for Adobe Commerce requires:
ext-bcmath
ext-ctype
ext-curl
ext-dom
ext-fileinfo
ext-filter
ext-gd
ext-hash
ext-iconv
ext-intl
ext-json
ext-libxml
ext-mbstring
ext-openssl
ext-pcre
ext-pdo_mysql
ext-simplexml
ext-soap
ext-sockets
ext-sodium
ext-spl
ext-tokenizer
ext-xmlwriter
ext-xsl
ext-zip
ext-zlib
lib-libxml
Magento Open Source requires:
ext-bcmath
ext-ctype
ext-curl
ext-dom
ext-fileinfo
ext-filter
ext-gd
ext-hash
ext-iconv
ext-intl
ext-json
ext-libxml
ext-mbstring
ext-openssl
ext-pcre
ext-pdo_mysql
ext-simplexml
ext-soap
ext-sockets
ext-sodium
ext-tokenizer
ext-xmlwriter
ext-xsl
ext-zip
ext-zlib
lib-libxml
To verify installed extensions:
List installed modules.
php -m
Verify that all required extensions are installed.
Add any missing modules using the same workflow used for installing PHP. For example, if you use yum
to install PHP, the PHP 7.4 modules can be added with:
yum -y install php74u-pdo php74u-mysqlnd php74u-opcache php74u-xml php74u-gd php74u-devel php74u-mysql php74u-intl php74u-mbstring php74u-bcmath php74u-json php74u-iconv php74u-soap
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.
PHP Warning: date(): It is not safe to rely on the system's timezone settings. [more messages follow]
Set the PHP memory limit.
Our detailed recommendations are:
1G
2G
~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 each time a page loads. See Performance Tuning in the PHP documentation.
Enable opcache.save_comments
, which is required for Adobe Commerce and Magento Open Source 2.1 and later.
We recommend you enable the PHP OPcache for performance reasons. The OPcache is enabled in many PHP distributions.
Adobe Commerce and Magento Open Source 2.1 and later use PHP code comments for code generation.
To avoid issues during installation and upgrade, we strongly recommend 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.
This section discusses how you find the configuration files necessary to update required settings.
php.ini
configuration fileTo find the web server configuration, run a phpinfo.php
file in your web browser and look for the Loaded Configuration File
as follows:
To locate the PHP command-line configuration, enter
php --ini | grep "Loaded Configuration File"
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.
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/7.2/fpm/php.ini
If you have more than one opcache.ini
, modify all of them.
To set PHP options:
Open a php.ini
in a text editor.
Locate your server’s time zone in the available time zone settings
Locate the following setting and uncomment it if necessary:
date.timezone =
Add the time zone setting that you found in step 2.
Change the value of memory_limit
to one of the values recommended at the beginning of this section.
For example,
memory_limit=2G
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
Save your changes and exit the text editor.
Open the other php.ini
(if they are different) and make the same changes in it.
To set opcache.ini
options:
Open your OPcache configuration file in a text editor:
opcache.ini
(CentOS)php.ini
(Ubuntu)/etc/php/7.2/fpm/php.ini
(nginx web server (CentOS or Ubuntu))Locate opcache.save_comments
and uncomment it if necessary.
Make sure that its value is set to 1
.
Save your changes and exit the text editor.
Restart your web server:
service apache2 restart
service httpd restart
service nginx restart
See the following Adobe Commerce Support articles for help with troubleshooting PHP problems: