This WordPress blog is running on an AWS Lightsail instance. The instance is based off a Bitnami WordPress stack. The instance contains core software that you need to run a WordPress site. With a clicks and configuration it is fairly easy to launch a new site.
However, the Bitnami stack is bundled in such a manner that it becomes difficult to upgrade software. The core software is version locked and cannot be upgraded easily.
Bitnami does provide upgrade instructions but they seem to describe the overall process more, than actually provide detailed step to carry out the task.
All software at some point of time will end up requiring update. It could be due to a new feature being released, bug fix or update to fix security issues discovered.
Few months ago, I noticed that when I logged into the WordPress admin console, there was a warning to upgrade the PHP version on the server. The version of PHP on the server was old and insecure.
The challenge was to find a way to upgrade the stack. I searched the Bitnami documentation and other sites on the internet, but none of the presented options seemed clear or viable.
I knew the best solution would be to move to a completely new AWS Lightsail instance. The instance would be based off a new OS image and fully patched as of it’s release date.
I kept putting off the upgrade, until I came across this post giving some clear answers to how a successful upgrade was done. Please do read the post as it lists detailed steps on the upgrade steps.
I followed the steps but in my case, I kept running into an issue with links being generated incorrectly by WordPress.
So, I had make a few changes to the upgrade process to complete and I am going to highlight those in this post.
Here is an overview of the steps I took to complete the entire process.
There was a short amount of downtime involved with my procedure, but after having two failed migrations, I knew I had to do things differently.
- Create an export of all WordPress data from existing instance.
- Take a Snapshot of your AWS Lightsail instance.
- Create a new Bitnami WordPress stack on AWS Lightsail.
- Change upload limits on the new AWS Lightsail instance.
- Change the DNS record for your blog to point to the new AWS Lightsail instance.
- Setup Let’s Encrpt SSL certificate on the new instance.
- Import data previously exported WordPress data to new instance.
- Reset the upload limits on the new AWS Lightsail instance.
- Install Redis Server
- Setup WordPress to use Redis.
- These steps worked for me when I migrated my site. This procedure resulted in a small downtime which may vary based on your sites content.
- For a short period of time, my site showed no content and if this is not acceptable, then this procedure is not suitable for your migration.
- It is possible that you may not get the same results, so please back up all your data and have a rollback plan.
- Please read the full post to understand the procedure.
- Redis is not mandatory, but since I had been using it, I decided to re-install and configure it.
- I take no responsibility for a failed migration or your inability to rollback to your old instance.
Snapshot, Backup and Export
Navigate to AWS Lightsail console, select your existing instance and create a snapshot for it. Hopefully you are not going to need this snapshot.
Login to your WordPress console and install the plugin for All-in-One WP Migration if you dont have it already.
The size of my site content is not very large and I confirmed that I could use the free version of the plugin.
Make sure you read the plugin documentation and confirm that it will work for you.
Once the backup is done, download the file to your local desktop and save it.
Note: I am not promoting the ‘All-in-One WP Migration’ plugin, you are free to use any plugin that allows you to Import/Export WordPress data.
New Bitnami WordPress AWS Lightsail instance
Create a new Bitnami WordPress AWS Lightsail instance which is similar to your current instance.
If you are planning to upgrade your instance, this would be a good time to do so.
Upload Limits And Configuration
The default limit in PHP configuration is 40 MB. If your WordPress export is bigger than 40 MB, you will have to modify the limits to allow the import to be successful.
Connect using SSH to your new Bitnami WordPress AWS Lightsail instance and using your favorite editor open up the php.ini file.
sudo vi /opt/bitnami/php/php.ini
Search and replace the upload limits for the variables post_max_size and upload_max_filesize to value larger than the size of your exported WordPress data.
In my instance I had to set it to 400 MB.
upload_max_filesize = 400M post_max_size = 400M
Save and exit the editor and restart services for the new values to take effect.
sudo /opt/bitnami/ctlscript.sh restart
Change the DNS for your site to point to the IP of the new Bitnami WordPress AWS Lightsail instance.
Note: As soon as the DNS change goes into effect, your site will come up with no content as we have not imported any of the data.
I use Cloudflare for my DNS, which makes it easy to set the DNS and TTL to switch the A record for my site.
See Bitnami SSL Guide for an overview of the procedure to get SSL certificate using Let’s Encrypt.
Install the Lego Client
Connect using SSH to the new instance.
Run the commands as shown to install the Lego client.
cd /tmp curl -Ls https://api.github.com/repos/xenolf/lego/releases/latest | grep browser_download_url | grep linux_amd64 | cut -d '"' -f 4 | wget -i - ls -l lego*.gz
See the version number in the file name that was downloaded and substitute the correct version in the next command. Replace X.Y.Z with real version.
tar xf lego_vX.Y.Z_linux_amd64.tar.gz sudo mkdir -p /opt/bitnami/letsencrypt sudo mv lego /opt/bitnami/letsencrypt/lego
Generate Certificate For Your Domain
For this to work properly, DNS must point to you new Instance.
Turn off all bitnami Services.
sudo /opt/bitnami/ctlscript.sh stop
Request a new certificate. Use your correct e-mail address and domain name.
sudo /opt/bitnami/letsencrypt/lego --tls --email="EMAIL-ADDRESS" --domains="DOMAIN" --domains="www.DOMAIN" --path="/opt/bitnami/letsencrypt" run
Configure The Web Server With New SLS Certificate
For Apache Self Contained Bitnami installation, run these steps. Replace DOMAIN with your WordPress site domain.
sudo mv /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apache2/conf/server.crt.old sudo mv /opt/bitnami/apache2/conf/server.key /opt/bitnami/apache2/conf/server.key.old sudo mv /opt/bitnami/apache2/conf/server.csr /opt/bitnami/apache2/conf/server.csr.old sudo ln -sf /opt/bitnami/letsencrypt/certificates/DOMAIN.key /opt/bitnami/apache2/conf/server.key sudo ln -sf /opt/bitnami/letsencrypt/certificates/DOMAIN.crt /opt/bitnami/apache2/conf/server.crt sudo chown root:root /opt/bitnami/apache2/conf/server* sudo chmod 600 /opt/bitnami/apache2/conf/server*
Edit your wp-config.php file and set your domain and other other custom setting that you may have in your old installation.
sudo vi /opt/bitnami/apps/wordpress/htdocs/wp-config.php
The theme from my existing site needs high memory limits, so I had to add as shown [Set your domain].
define( 'WP_MEMORY_LIMIT', '128M' ); define( 'WP_SITEURL', 'https://yourdomain.com'); define( 'WP_HOME', 'https://yourdomain.com');
Save and exit the file.
Restart all Bitnami services
sudo /opt/bitnami/ctlscript.sh start
Import Data Into WordPress
find credentials to login to your new WordPress site by running this command.
sudo cat /home/bitnami/bitnami_credentials
If for some reason you are unable to locate the file, follow this post to find your Bitnami credentials.
Login to you WordPress Admin console. Since we already changed our DNS earlier, the login URL will be the same as what you are used too.
It should be something similar to
If you decided to use a different plugin, than the one I used, go ahead and install that plugin, otherwise install and activate the ‘All-in-One WP Migration’ plugin.
On the Left Navigation menu, select the Plugin import option and start the import process by selecting the previously downloaded export file and proceeding with the import.
After the import is complete, you should check your site. All your plugins, images, content should be visible in the Admin console.
Navigate to your site URL and confirm that the site looks the same as before.
Hopefully, all the content is there and your site is functioning as expected!
Reset upload limits that you had changed before in the file php.ini and restart all services.
Note: To setup a script to automatically renew the certificate after 90 days, see this post.
That’s it folks, you have successfully ‘Updated Bitnami WordPress Stack Running on AWS Lighsail’.
Let me know if you have any questions or need help with this by commenting below.
Consider installing Redis to improve performance of your site.
I had posted two articles to enable Redis on WordPress earlier. Both posts have been updated recently as I installed Redis on the new Bitnami Stack.
Thank you! This helped a lot 🙂