This topic discusses how to set required PHP options.
- Magento 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.
- Docker let you to do it with the help of port forwarding. First run docker ps -a, find your container id, usually the very first column and then run the command like docker port 8dbfe2506534 where 8dbfe2506534 is my container id. Even if you just do a docker ps -a you can see how a port is being.
- 今回はDockerを使ってnginx上でPHP実行環境を構築し、Laravel新規プロジェクト作成までを行います。 環境. Dockerとdocker-composeは用意できている前提です。 Docker version 18.06.0-ce docker-compose version 1.22.0. 以下の構成を想定しています。 project ├ docker-compose.yml ├ docker.
Magento supports PHP 7.4.0. You can install Magento 2.4.0 with 7.3, but it is not tested or recommended. It is intended for upgrading from Magento 2.3.x to Magento 2.4.0.
Note: We do not endorse the use of Watchtower as a solution to automated updates of existing Docker containers. In fact we generally discourage automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, we highly recommend using Docker Compose.
There is a bug in PHP 7.4.2 which causes some messages to not render properly. Magento recommends using other versions of 7.4.There is a bug in the psr
php extension which causes fatal errors during installation or upgrade. Magento recommends uninstalling or deactivating the psr
php extension.
Verify PHP is installed
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:
If PHP is installed, a message similar to the following displays:
Magento 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.
Verify installed extensions
Magento requires a set of extensions to be installed:
ext-bcmath
ext-ctype
ext-curl
ext-dom
ext-gd
ext-hash
ext-iconv
ext-intl
ext-mbstring
ext-openssl
ext-pdo_mysql
ext-simplexml
ext-soap
ext-xsl
ext-zip
ext-sockets
To verify installed extensions:
List installed modules.
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:
Check PHP settings
- 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:
Set the PHP memory limit.
Our detailed recommendations are:
- 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: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 Magento 2.1 and later.We recommend you enable the PHP OPcache for performance reasons. The OPcache is enabled in many PHP distributions.
Magento 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.
Step 1: Find PHP configuration files
This section discusses how you find the configuration files necessary to update required settings.
Find php.ini
configuration file
Pdo_mysql Docker Wordpress
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
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.
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:
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.
Step 2: How to set PHP options
To set PHP options:
Php-fpm Pdo_mysql Docker
- 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:
Add the time zone setting 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,
Add or update the
realpath_cache
configuration to match the following values:Save your changes and exit the text editor.
- Open the other
php.ini
(if they are different) and make the same changes in it.
Step 3: 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/7.2/fpm/php.ini
(nginx web server (CentOS or Ubuntu))
- Locate
opcache.save_comments
and uncomment it if necessary. - Make sure 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
Pdo_mysql.default_socket Docker
See the following Magento Support articles for help troubleshooting PHP problems: