After modifying php.ini under Linux, what is the method for php to take effect? This article will introduce how to make it effective after modifying php.ini on the Linux server.
1. What is php.ini
PHP is a programming language, and php.ini is the main configuration file of PHP. PHP loads and controls various settings through this file, such as explicit error output, logging, maximum execution time, memory limits, etc.
2. Modify php.ini
Find the php.ini file on the Linux server. Generally, the file is in the /etc/php/ directory. Its location and name can be determined according to the specific Configuration to determine. You can use the command line to open the file:
sudo nano /etc/php/7.2/apache2/php.ini
The 7.2
here should be the php version you installed yourself. When using different versions of php, this number should change accordingly.
In this file, users can modify many settings. For example:
When a PHP error occurs, the user may see an error message. Users can override this default behavior.
; display_errors是否在服务器环境中解释,0表示“不”,1表示“是”。 display_errors = Off
Here, the user can change "Off" to "On", so that PHP errors will be displayed in the server environment to facilitate debugging.
Users can also specify which file to send error information to, such as:
; error_log指定了PHP错误日志文件的路径。 error_log = /var/log/php-errors.log
In this way, all PHP errors will be recorded to /var/ log/php-errors.log file.
The php.ini file can also modify the memory limit of PHP scripts. Users can use the following settings:
; 在运行脚本时使用20M的内存 memory_limit = 20M
In this example, 20M represents the maximum memory limit. .
3. Restart the Apache server
When you modify the php.ini file, the modification will take effect. There are many PHP modules in the Apache server, so when you modify php.ini, you need to restart the Apache server, as shown below:
sudo systemctl restart apache2
This command will stop the Apache server and start it. If the modification does not take effect, It is recommended to check /var/log/apache2/error.log to confirm the problem.
Now, PHP should restart with the updated settings.
Summary
PHP is a very popular programming language, and the php.ini file is the main configuration file of PHP. Modifying php.ini can control many behaviors of PHP, such as enabling error messages, recording error logs, modifying memory limits, etc. When the modification is completed, you need to restart the Apache server for the settings to take effect.
The above is the detailed content of What is the method for php to take effect after modifying php.ini in Linux?. For more information, please follow other related articles on the PHP Chinese website!