Wordpress upload file size error even after raising php limits

March 13, 2018 1k views
WordPress PHP Nginx CentOS

Hey all,
I get 'The uploaded file exceeds the uploadmaxfilesize directive in php.ini.' error while trying to upload a plugin which is just 5.1MB.
I have raised the limits in php.ini file and also thru webmin.

This is my php.ini file

 max_input_time = 24000
 max_execution_time = 24000
 upload_max_filesize = 12000M
 post_max_size = 24000M
 memory_limit = 12000M

Here is my nginx.conf file. I have also increased clientmaxbody_size under server and http.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    client_max_body_size 24000M;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
.........
server_names_hash_bucket_size 128;
    server {
        client_max_body_size 24000M;
        server_name thesatlight.com www.thesatlight.com;
.....

What could be the problem?

4 Answers

@akaab

Make sure that you are modifying the INI file used by your web server not the one used by PHP CLI.

You can create a PHP file called info.php with the following content

<?php
   phpinfo();
?>

Then open the page in your web browser and make sure the options you changed are applied to the runtime configuration, if they are not applied then try to restart Nginx with this command sudo service nginx restart

Open the page after restart if the values are not applied then you are not modifying the right php.ini file used by your web server.

Hope this helps.

  • Thank you for answering. But I am not able to restart nginx using the command sudo service nginx restart. I get this error env: /etc/init.d/nginx: Permission denied
    I tried restarting using the command systemctl restart nginx.service. But when I visit the info.php file it returns a 404 not found error. Also, I am sure I am modifying the right file because I do it from Virtualmin. I also tried creating a new php.ini in my public_html folder but that also did not work. Is it something to do with nginx restarting?

  • I went ahead and created the info.php file using the file manager in Virtualmin. And yes has you pointed, the changes are not reflected. How do I edit the right file?

    • In the web page info.php you can find the Loaded Configuration File which points to the file which you must edit for changes to take effect.

      Hope this helps.

      • Hey, I was modifying the right file. The changes are reflected in the file. But not in the info page. Also I'm not able to restart nginx using sudo service nginx restart. What can be the problem? Also the t settings are also ger than the plugin size. The plugin is just 1.2 mb but it still won't let me upload.

        • Why you cannot restart? Can you print the last few lines of Nginx error log?

          • 2018/03/14 09:57:25 [error] 21503#0: *621 open() "/usr/share/nginx/html/_phpmyadmin/scripts/setup.php" failed (2: No such file or directory), client: 185.172.110.202, server: _, request: "GET /_phpmyadmin/scripts/setup.php HTTP/1.1", host: "159.65.238.149"
            2018/03/14 12:15:21 [emerg] 18786#0: unknown directive "upload_max_filesize" in /etc/nginx/nginx.conf:93
            2018/03/14 12:16:06 [emerg] 18984#0: unknown directive "upload_max_filesize" in /etc/nginx/nginx.conf:131
            2018/03/14 12:20:50 [error] 21503#0: *708 open() "/usr/share/nginx/html/muieblackcat" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET /muieblackcat HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:20:50 [error] 21503#0: *709 open() "/usr/share/nginx/html/phpMyAdmin/scripts/setup.php" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET //phpMyAdmin/scripts/setup.php HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:20:51 [error] 21503#0: *710 open() "/usr/share/nginx/html/phpmyadmin/scripts/setup.php" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET //phpmyadmin/scripts/setup.php HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:20:51 [error] 21503#0: *711 open() "/usr/share/nginx/html/pma/scripts/setup.php" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET //pma/scripts/setup.php HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:20:51 [error] 21502#0: *712 open() "/usr/share/nginx/html/myadmin/scripts/setup.php" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET //myadmin/scripts/setup.php HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:20:51 [error] 21503#0: *713 open() "/usr/share/nginx/html/MyAdmin/scripts/setup.php" failed (2: No such file or directory), client: 65.52.123.63, server: _, request: "GET //MyAdmin/scripts/setup.php HTTP/1.1", host: "174.138.125.5"
            2018/03/14 12:21:39 [emerg] 19506#0: unknown directive "client_upload_max_filesize" in /etc/nginx/nginx.conf:93
            
          • Remove the unkown directives and show me the page info.php

            On my server it shows this line

            Loaded Configuration File /etc/php/7.1/apache2/php.ini

            Which means I should modify /etc/php/7.1/apache2/php.ini then restart apache for changes to take effect.

            To make sure after restarting re-visit the page and you should see the new values

            upload_max_filesize 50M

  • @akaab You should check if you have configured

    upload_max_filesize 24000M;
    

    in your nginx configuration.

@Mohsen47 I have edited the same file. Here is the php info page https://thesatlight.com/info.php

@akaab

Edit this file /home/thesatlight/etc/php7.0/php.ini and make sure you have the required values in it also make sure these values are not defined in any file inside this directory /etc/opt/rh/rh-php70/php.d.

Then tell me if the issue is resolved.

  • @akaab you can find me on Facebook if you like and we can chat there. We can setup a shared terminal session if you like and I will help you figure it out.

Have another answer? Share your knowledge.