How can I increase the PHP upload size limit in my Lightsail Bitnami WordPress instance?
Last updated: 2021-09-23
I want to upload large files onto my Amazon Lightsail Bitnami WordPress instance. How can I increase the default file upload limit on my instance?
Upload_max_filesize is the maximum size of an uploaded file. This is the limit for a single file. Post_max_size, on the other hand, is the limit of the entire body of the request. It's a best practice that you set the post_max_size to be 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 limit on your Lightsail instance, run the following commands:
# grep -i "upload_max_filesize" /opt/bitnami/php/etc/php.ini upload_max_filesize = 40M
# grep -i "post_max_size" /opt/bitnami/php/etc/php.ini post_max_size = 40M
To modify the maximum upload size, do the following:
1. Open the /opt/bitnami/php/etc/php.ini file to increase upload_max_filesize and post_max_size. 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 the i button to edit the values. After modifying the values, save the file by pressing the ESCAPE button. Then, enter the command :wq!
3. Verify that the LimitRequestBody parameter is specified in the Apache configuration files using the following command:
# grep "LimitRequestBody" /opt/bitnami/apache2/conf/httpd.conf
If the parameter isn't specified, then there is no size restriction in the Apache web server configuration limits. However, if the parameter is specified and the value is less than the desired upload size, increase the parameter by doing the following:
Open /opt/bitnami/apache2/conf/httpd.conf in a text editor such as the vi editor:
# sudo vi /opt/bitnami/apache2/conf/httpd.conf
Set the LimitRequestBody parameter to a new value in bytes, as shown in the following example:
Press the ESCAPE button and then enter the command :wq! to save the file.
4. Check the configuration details before restarting the services:
sudo apachectl configtest
5. Restart the servers for the changes to take effect.
sudo /opt/bitnami/ctlscript.sh restart