Home > Backend Development > PHP Problem > How to modify the php.ini file in nginx environment and make it effective

How to modify the php.ini file in nginx environment and make it effective

PHPz
Release: 2023-03-29 15:27:28
Original
1307 people have browsed it

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:

  1. Open the php.ini file

Use the vim editor to open the php.ini file:

vim /etc/php.ini
Copy after login
  1. Modify the php.ini file

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
Copy after login

to:

post_max_size = 100M
Copy after login
  1. Save and exit

Press the "Esc" key to exit the editing mode, enter the ":wq" command to save and exit.

  1. Restart nginx service

After modifying the php.ini file, you need to restart the nginx service to make it take effect:

systemctl restart nginx
Copy after login

This will restart the nginx service , to make the modified php.ini file take effect.

  1. Check whether php.ini is valid

Create a phpinfo.php file on the Web server, copy and save the following content:

<?php
phpinfo();
?>
Copy after login

Then Enter the following address into your browser:

http://ip地址/phpinfo.php
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template