How to modify the file upload size limit of Nginx and PHP

  • 2021-07-18 07:15:30
  • OfStack

1. Modify 3 items in the PHP configuration file: vim/usr/local/php/etc/php. ini

(1) post_max_size = 50M # PHP Maximum acceptable POST data

(2) upload_max_filesize = 50M # Maximum allowed file upload

(3) max_execution_time = 300 # Maximum execution time per script in seconds (0 is unlimited, 0 is not recommended)

2. Modify the Nginx configuration file: vim/usr/local/nginx/conf/nginx. conf (If you forget the exact location of the configuration file, you can find it using locate nginx. conf)

(1) client_max_body_size 50m # Client Max Upload Size 50M

3. Restart PHP:/etc/init. d/php-fpm restart

4. Smooth restart of Nginx:/usr/local/nginx/sbin/nginx-s reload


Related articles: