skip to Main Content

I want to upload a large Excel file. But because the file contains many rows, the loading is so slow and I got this error:

local.ERROR: Maximum execution time of 30 seconds exceeded {"userId":3,"exception":"[object] (SymfonyComponentErrorHandlerErrorFatalError(code: 0): Maximum execution time of 30 seconds exceeded

I’m using Laravel 10.

I tried to edit the php.ini files in two different locations since I’m using Ubuntu Server 22.04

I changed it here

/etc/php/8.1/cli/php.ini

And here:

 /etc/php/8.1/fpm/php.ini

To these settings, equally on both files:

 max_input_time = 3600
 max_execution_time = 3600
 upload_max_filesize = 6000M
 post_max_size = 12000M
 memory_limit = 6000M

But I’m still getting these errors, and I don’t know why, the only solution was to set the configs directly on the Laravel index.php like this

set_time_limit(3600);
ini_set('memory_limit', '6000M');

My nginx config for the API is:

server {

    server_name api.domain.test;
    root /var/www/api/public;

    gzip on;
    gzip_types      text/plain application/xml text/css;
    gzip_proxied    no-cache no-store private expired auth;
    gzip_min_length 1000;
    server_tokens off;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    add_header X-XSS-Protection "1; mode=block";
    add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval'";

    add_header Referrer-Policy "strict-origin";

    index index.php;

    charset utf-8;

    location /api/ {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 403 /index.php;

    location ~ .php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_read_timeout 600;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.(?!well-known).* {
        deny all;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/api.net4co2.info/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/api.net4co2.info/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

I uploaded a image from my phpinfo
PHP Info print

When I have the remote XDebug on, everything works fine, but when I disable it, It’s like that the PHP don’t read anymore from these php.ini files.
Can someone help me why changing the config on php.ini not working?

2

Answers


  1. Chosen as BEST ANSWER

    So after the @CBroe told me that some of my "additional ini files parsed" could be overwritten, the changes.

    The solution that I found was to create my own config file on /etc/php/8.1/fpm/conf.d called 99.overrides.php.ini and then I added this lines of it

    priority=99
    max_input_time = 12000
    max_execution_time = 12000
    upload_max_filesize = 1G
    post_max_size = 2G
    memory_limit = 6000M
    

    After this, the changes are applied and override everything else.


  2. Did you try to read only few row, per example, 3 rows? works fine?
    I had the same problem. My script works fine with few rows but with a lot of rows trhow me an error because a TimeOut. So, you only put at the begining of my script this:

    set_time_limit(0);
    

    And Inside my code I processed using **Try Catch** for any unexpected error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search