Search code examples
laravelamazon-web-servicesforge

Increase upload_max_filesize via Forge


Error: 413 Request Entity Too Large

I have attempted to increase upload_max_filesize to 20M using the Edit PHP FPM Configuration and Edit PHP CLI Configuration tools in Laravel Forge. It successfully saves my settings, but the changes don't seem to take affect. I have tried restarting nginx and the server.

Environment:

  • AWS EC2
  • nginx

Solution

  • I was missing a piece. Here's the whole answer.

    Nginx Configuration

    Add the following line to http or server or location context to increase the size limit in nginx.conf:

    # set client body size to 20M #
    client_max_body_size 20M;
    

    PHP Configuration

    Edit php.ini and set the following directives:

    ;This sets the maximum amount of memory in bytes that a script is allowed to allocate
    memory_limit = 256M
    
    ;The maximum size of an uploaded file.
    upload_max_filesize = 20M
    
    ;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
    post_max_size = 30M
    

    Source: http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/