chrispytoes chrispytoes - 3 years ago 108
PHP Question

Max filesize not taking effect from php.ini

I know this is a massive repost but I couldn't figure this out. The server is Ubuntu using nginx.


I see the configuration file I am using is

These are the properties I set:

upload_max_filesize = 256M
post_max_size = 256M

I restarted nginx, as well as the
process and the max upload size is still not changing.

I am using wordpress so as a last resort I even tried using a plugin that increases the max upload size and even that didn't work.

I also tried setting it in my .htaccess as well and still nothing:

php_value post_max_size 256M
php_value uploads_max_filesize 256M

Answer Source

By default NGINX has a limit of 1MB on file uploads. To change this you will need to set the client_max_body_size variable. You can do this in the http block in your nginx.conf

http {
        client_max_body_size 100m;
        client_body_timeout 120s; # Default is 60, May need to be increased for very large uploads

If you are expecting upload very large files where upload times will exceed 60 seconds you will also need to add the client_body_timeout variable with a large value

After updating you NGINX configuration don’t forget to restart NGINX.

you need to restart nginx and php to reload the configs. This can be done using the following commands;

sudo service nginx restart
sudo service php7.0-fpm restart

Note:if you don't have to host multiple Websites just add it to the server block

server {
    client_max_body_size 8M;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download