If you've ever needed to upload large files onto your WordPress installation, you've probable come across the dreaded upload limit. Each limit depends on the platform hosting your installation, but typically you can only upload around 64M in one go until you get stopped. On new installations we come across this issue all the time and typically fix it by editing the functions.php file. The most common time you'll need to change this is when migrating a dev site to a live domain (this is at least the case for us). If you're doing this you're probably using the All-in-One WP Migration plugin.
On Lightsail, the process of increasing that memory limit is a bit different then a traditional cpanel host setup, but once you learn how to do it, it's pretty simple. It's the action of gathering all of the information is a bit difficult, so that's why we're publishing this quick guide on how to increase the memory limit from 40M on Amazon Lightsail WordPress installations for someone not familiar with the platform.
There are a few ways to increase memory on a WordPress installation, and for this use case, the best way to do this is the edit/add values in the PHP.ini file. Here's what we need to change/add:
upload_max_filesize = 40M
post_max_size = 40M
max_execution_time = xxx --> it's optional to change this
We need to access the PHP.ini file. To do this we will access the installation files via a desktop FTP client. This is helpful for those who are unfamiliar with SSH or terminal commands. Follow these steps:
Acquire the login information needed to log into the instance via SFTP. You'll need to find the following:
To get the SSH Key, navigate to the "connect" section on the Lightsail dashboard. Scroll all the way down and click on the account page link.
Download the key that corresponds to the listed Key Pair. In this example its Default, US East 1.
The public IP, which is your Host, can be found in your Lightsail dashboard.
If you installed WordPress via Bitnami, the SFTP Username is Bitnami.
We use Filezila as our client. You can add this site by the key combo CTRL-S. Here's the final configuration:
Now login via SFTP and locate the PHP.ini file.
It should be located at: /opt/bitnami/php/etc
Edit the file, changing the values under these entries:
upload_max_filesize = 40M
post_max_size = 40M
max_execution_time = xxx --> it's optional to change this
A quick way to to this is find and replace: typically CTRL+H, search for 40M and replace it with whatever value you want.
Save the file and overwrite it to push the changes to the server.
The final step is to simply reboot the instance. Many people will go from editing the file to refreshing the page expecting to see the increased limit and skip this step. You need to reboot to apply these changes. Do so by heading to the Lightsail dashboard and clicking the reboot button.
After the server is back online you can refresh the page and see the new upload limit.
I hope this helped and provided a quick and simple guide on how to increase the pesky upload limit for a WordPress installation on AWS' Lightsail product.