Some common errors users get when dealing with file uploads with WordPress are Http errors attempting to upload media, the uploaded file exceeds the upload_max_filesize directive in php.ini, maximum execution time exceeded, allowed memory size exhausted, and many more. This brief tutorial is going to show students how to resolve some of these issues with WordPress running on Nginx and PHP-FPM on Ubuntu 17.04 | 17.10 Before continuing with the steps below, please make sure to back up your system.
Configure WordPress Directory Permissions
First, make sure the directory WordPress is running in has the correct permission for the Nginx web server to operate. On Ubuntu systems, the root directory is almost always at /var/www/html. So, run the commands below to give Nginx web server full access to that directory.
Adjust PHP-FPM Setting
Next, adjust PHP-FPM settings to allow larger file uploads. By default, PHP-FPM is only allowed to upload a certain file size. so there’s a limit. Adjust the file upload size limit and other directives in PHP-FPM. On Ubuntu 17.04 and up, the default PHP-FPM configuration file is stored in the file below: /etc/php/7.x/fpm/php.ini The x in the line above can either be a 0 or 1 So, open the PHP-FPM configuration file by running the commands below and adjust the settings to suit your environment. Then scroll down the file line by line and adjust each directive with the value below: Save your changes. If the file size you’re uploading is greater than 100MB, then adjust the upload_max_filesize to be greater than the file size.
Adjust Nginx Configuration
Nginx also has limited definitions. If you don’t define the size limit in the Nginx configuration, whatever you do in the PHP configuration file may not apply to Nginx. To allow Nginx to also upload a larger file, open Nginx configuration and add the values as defined below: On Ubuntu systems, Nginx default site configuration files are stored at /etc/nginx/sites-available/default If you have a custom file in there, adjust the highlighted values also. Save the file and continue Finally, restart Nginx and PHP-FPM for the new settings to take effect This should do it. Now go and try to upload the file you want with a size smaller than 100MB Enjoy~ You may also like the post below: