How do I increase the PHP upload size limit in my Lightsail Bitnami WordPress instance?

2 minute read
0

I want to upload large files onto my Amazon Lightsail Bitnami WordPress instance.

Short description

Upload_max_filesize is the maximum size and quota of a single uploaded file. Post_max_size is the quota of the entire body of the request. It's a best practice to set post_max_size as greater than or equal to upload_max_filesize. By default, WordPress limits uploads to 40 MB for both post_max_size and upload_max_filesize.

To verify the maximum upload quota on your Lightsail instance, run the following commands:

# grep -i "upload_max_filesize" /opt/bitnami/php/etc/php.ini
# grep -i "post_max_size" /opt/bitnami/php/etc/php.ini

The commands give an output similar to the following:

upload_max_filesize = 40M
post_max_size = 40M

Resolution

To modify the maximum upload size, complete the following steps:

  1. To increase upload_max_filesize and post_max_size, open the /opt/bitnami/php/etc/php.ini file. Use a text editor, such as the vi editor, to access the /opt/bitnami/php/etc/php.ini file:

    # sudo vi /opt/bitnami/php/etc/php.ini
    
    ; Maximum size of POST data that PHP will accept.  
    post_max_size = 64M
    
    ; Maximum allowed size for uploaded files.  
    upload_max_filesize = 64M
  2. Press i to edit the values, and then press Esc to save the file. Then, run the following command to save the file:

    :wq!
  3. To verify that the LimitRequestBody parameter is specified in the Apache configuration files, run the following command:

    # grep "LimitRequestBody" /opt/bitnami/apache2/conf/httpd.conf

    If the parameter isn't specified, then there's no size restriction in the Apache web server configuration limits. If the parameter is specified and the value is less than the intended upload size, then complete the following steps to increase the parameter:
    Open /opt/bitnami/apache2/conf/httpd.conf in a text editor:

    # sudo vi /opt/bitnami/apache2/conf/httpd.conf

    Set the LimitRequestBody parameter to a new value in bytes:

    LimitRequestBody 65536

    Press Esc, and then run the following command to save the file:

    :wq!
  4. To check the configuration details, run the following command:

    sudo apachectl configtest
    Syntax OK
  5. For the changes to take effect, run the following command to restart the servers:

    sudo /opt/bitnami/ctlscript.sh restart
AWS OFFICIAL
AWS OFFICIALUpdated 2 months ago