How to increase the maximum file upload size in PHP-FPM?

To increase the maximum file upload size in PHP-FPM, you need to modify several configuration settings. Follow the steps below:

  1. Locate the php.ini file: First, you need to find the php.ini file used by your PHP installation. You can do this by checking the output of the phpinfo() function or running the command php --ini on the command line.

  2. Edit the php.ini file: Open the php.ini file in a text editor.

  3. Increase upload_max_filesize: Look for the upload_max_filesize directive in the php.ini file. This directive determines the maximum size of an uploaded file. Increase the value according to your needs. For example, change upload_max_filesize = 2M to upload_max_filesize = 20M for a maximum upload size of 20 megabytes.

  4. Increase post_max_size: Find the post_max_size directive in the php.ini file. This directive determines the maximum size of POST data that PHP will accept. Make sure to set it to a value greater than or equal to upload_max_filesize. For example, change post_max_size = 8M to post_max_size = 20M.

  5. Save the changes and restart PHP: Save the php.ini file and restart the PHP-FPM service to apply the changes. The exact command to restart PHP-FPM depends on your operating system and how you have it installed. Some common commands include service php-fpm restart, systemctl restart php-fpm, or systemctl restart php7.4-fpm.

After completing these steps, PHP-FPM should have an increased maximum file upload size. You can test it by uploading a file using a form on your website.