PHP settings
This topic discusses how to set required PHP options.
For Cloud configuration guidance, see PHP settings in the Commerce on Cloud Infrastructure guide.
PHP Process Control
Before you can run indexers in parallel mode, you must enable Process Control support (pcntl
) in PHP. See Installation in the PHP documentation.
Verify PHP is installed
PHP is installed by default on most Linux distributions. This topic assumes that you have already installed PHP. To verify if PHP is installed, enter the following on the command line:
php -v
If PHP is installed, a message similar to the following displays:
PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
If PHP is not installed (or requires an upgrade), install it by following the instructions for your Linux distribution.
Verify installed extensions
Adobe Commerce and Magento Open Source require certain PHP extensions. The following lists specify required extensions for each edition of Commerce. The lists are autogenerated from a deployment running the latest version of each edition.
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.
code language-bash php -m
-
Verify that all required extensions are installed.
-
Add any missing modules using the same workflow used for installing PHP.
Check PHP settings
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
- Compiling code or deploying static assets,
-
Increase the values for the PHP
realpath_cache_size
andrealpath_cache_ttl
to recommended settings:code language-conf 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 and Magento Open Source 2.1 and later.Adobe recommends enabling 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.
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:
To locate the PHP command-line configuration, enter
php --ini | grep "Loaded Configuration File"
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:
code language-bash 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:
-
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:
code language-conf 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,
code language-conf memory_limit=2G
-
Add or update the
realpath_cache
configuration to match the following values:code language-conf ; ; 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.
Set OPcache options
To set opcache.ini
options:
-
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))
-
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:
- Apache, Ubuntu:
service apache2 restart
- Apache, CentOS:
service httpd restart
- nginx, Ubuntu and CentOS:
service nginx restart
- Apache, Ubuntu:
Troubleshooting
See the following Adobe Commerce Support articles for help with troubleshooting PHP problems: