How to modify php.ini in centos: first use the phpinfo function to find the location of "php.ini"; then use Xshell to connect to the server; then enter the file and search for keywords; and finally modify it through the operation command.
Recommended: "centos Getting Started Tutorial" "PHP Video Tutorial 》
1.php.ini attribute default value
file_uploads = on ;Switch whether to allow file uploading through HTTP. The default is ON
upload_tmp_dir; Files are uploaded to the server where temporary files are stored. The default is the system default temporary folder.
upload_max_filesize: The maximum size of files allowed to be uploaded. The default is 2M
post_max_size: refers to the maximum value that can be received through POST to PHP through the form, including all values in the form. The default is 8M
max_execution_time: The maximum time value (seconds) for each PHP page to run, the default is 30 seconds
max_input_time: The maximum time required for each PHP page to receive data, the default is 60 seconds
Change to (reference)
max_execution_time = 600
max_input_time = 600
file_uploads = on
upload_tmp_dir = /tmp
upload_max_filesize = 32m
post_max_size = 32m
2. Configure php.ini
Restart the Apache server
Centos (7)/Linux
1. Find php.ini
Create php file and use it The phpinfo() function finds the location of php.ini
echo phpinfo();
as shown in the picture:
2. Use Xshell to connect to the server and vi to edit the file
# vi /etc/php.ini
3. Enter the file and search for keywords (see the beginning, just change it to what you want)
1) In command mode (press ESC to enter, if there is no response, just type the command) and hit the slash lever ( / ) 2) "/" appears in the status bar (lower left foot of the screen). Enter the keyword you are looking for and press Enter.
3) If you want to continue to search for this keyword, type the character n / type the character N (capital N) to search forward;
4. Modify,
The following is the command Some operation commands in mode
Operation | Analysis |
---|---|
i | Enter text editing mode |
Esc | Exit text editing mode |
:w | Save the current modifications but do not exit |
:q | Exit vi without saving the file |
:wq | Save the current modifications and exit vi |
:q! | Do not save the file and force exit vi |
:e! | Discard all changes and start editing again from the last time you saved the file |
5.php.ini needs to be restarted after modification Apache server (the Internet says to restart PHP, my attempt failed, and it succeeded after restarting Apache)
1) PHP start, stop and restart commands
service php-fpm start
service php-fpm stop
service php-fpm reload
2) Apache start stop and restart command
service httpd start start
service httpd restart restart
service httpd stop Stop the service
6. Attached check the reason why the file upload failed
$_FILES['file']['error'] Display the error code related to the file upload
The above is the detailed content of How to modify php.ini in centos. For more information, please follow other related articles on the PHP Chinese website!