Home > Article > Backend Development > How to modify the php.ini file in nginx environment and make it effective
When using PHP to develop a website, it is usually necessary to modify the PHP configuration file php.ini to meet specific business needs, such as changing memory limits, upload file size limits, etc. However, after modifying the php.ini file, PHP will not take effect immediately. You need to restart the web server or the PHP-FPM process pool to take effect. This article will introduce how to modify the php.ini file in the nginx environment and make it effective.
We assume that you are using the CentOS 7 operating system, have installed nginx and PHP, and the php.ini configuration file is located in the /etc/php.ini path. The steps to modify the php.ini file are as follows:
Use the vim editor to open the php.ini file:
vim /etc/php.ini
Find the configuration item that needs to be modified. For example, if we want to modify post_max_size to 100M, modify the following configuration item:
post_max_size = 8M
to:
post_max_size = 100M
Press the "Esc" key to exit the editing mode, enter the ":wq" command to save and exit.
After modifying the php.ini file, you need to restart the nginx service to make it take effect:
systemctl restart nginx
This will restart the nginx service , to make the modified php.ini file take effect.
Create a phpinfo.php file on the Web server, copy and save the following content:
<?php phpinfo(); ?>
Then Enter the following address into your browser:
http://ip地址/phpinfo.php
where "ip address" is the IP address of your web server. If you see that the value of post_max_size in the phpinfo.php page has been modified to 100M, it means that the php.ini file has been successfully modified and taken effect.
Summary
After modifying the php.ini file, you must restart the web server or PHP-FPM process pool to take effect, otherwise the configuration modification will not take effect. In the nginx environment, after modifying the php.ini file, you need to restart the nginx service for it to take effect. If you need to confirm whether the modification to the php.ini file has taken effect, you can verify it by creating the phpinfo.php file.
The above is the detailed content of How to modify the php.ini file in nginx environment and make it effective. For more information, please follow other related articles on the PHP Chinese website!