Featured image of post How to Upgrade Bitnami Wordpress stack

How to Upgrade Bitnami Wordpress stack

Bitnami make it easy to deploy open source applications. In this article you will learn the upgrade process of a bitnami wordpress image to a newer version.

Bitnami make it easy to deploy open source applications in public clouds (AWS, Azure or GCP), docker images and virtual machines for hundreds of applications. These images come with pre-installed, optimized and secured applications. They also provide additional tools like Let’s encrypt free HTTPS certificate generator or automatic disk expand/shrink on reboot to help you accelerate your build.

If you used AWS Lightsail service to build a linux server, you most likely came across a bitnami application images such as LAMP, Wordpress and MySQL.

Bitnami images are often built on top of debian, so they have apt as the package manager. However, bitnami packages cannot be updated through apt store. The upgrade process is completely manual. In this article you will learn the upgrade process of a bitnami image to a newer version.

I will be using Wordpress bitnami image for AWS cloud as an example, but you can replicate the following steps for similar images running Apache, PHP, MySQL or Mariadb. For cross platform migrations (Apache to NGINX or vice versa) you may need additional steps due to different configuration syntax.

  1. If you are using extended firewall in your application such as Wordfence extended protection, it’s recommended to disable this option temporarily.
  2. SSH to the old bitnami server using an SSH client.
  3. Stop all services and start mysql or mariadb to do the database backup:
1
2
3
sudo /opt/bitnami/ctlscript.sh stop
sudo /opt/bitnami/ctlscript.sh start mariadb
sudo /opt/bitnami/ctlscript.sh status
  1. Execute mysqldump command to backup the application database named bitnami_wordpress into a file named mysqldump2023.sql, and enter MySQL/Mariadb root password (located at /home/bitnami/bitnami_credentials):
1
2
cd /home/bitnami
sudo mysqldump -u root -p bitnami_wordpress > mysqldump2023.sql
  1. Compress Wordpress main directory while maintaining symlinks:
1
2
cd /opt/bitnami/wordpress/
sudo zip -r /home/bitnami/optbitnami.zip * --symlinks
  1. Compress Wordpress media directory:
1
2
cd /bitnami/wordpress/
sudo zip -r /home/bitnami/bitnami.zip *
  1. Deploy new bitnami server from AWS marketplace or Lightsail console. Feel free to change CPU, RAM and disk size if you need to. Upload the new instance key file pem into the old server’s /home/bitnami directory. In summary the old server’s /home/bitnami directory should have these following 4 files:
1
2
3
4
5
cd /home/bitnami
mysqldump2023.sql
optbitnami.zip
bitnami.zip
newkey.pem
  1. Fix newkey.pem key permissions in old server:
1
chmod 600 newkey.pem
  1. Use scp to transfer the backup files from old to new server, where 34.228.112.230 represents new public server IP address. Since scp is an encrypted protocol we are not worried about using the server private IP for file transfer:
1
2
3
scp -i newkey.pem optbitnami.zip bitnami@34.228.112.230:/opt/bitnami/wordpress/
scp -i newkey.pem bitnami.zip bitnami@34.228.112.230:/home/bitnami
scp -i newkey.pem mysqldump2023.sql bitnami@34.228.112.230:/home/bitnami
  1. SSH to the new bitnami server using an SSH client.
  2. Wipe existing Wordpress main directory, then extract the backup zip file:
1
2
3
4
cd /opt/bitnami/wordpress/
sudo rm -v -r !("optbitnami.zip")
sudo unzip optbitnami.zip
sudo rm optbitnami.zip
  1. Navigate to Wordpress media directory, and copy database user info from new wp-config.php before deletion:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
nano /bitnami/wordpress/wp-config.php

/** Database username */

define( 'DB_USER', 'bn_wordpress' );


/** Database password */

define( 'DB_PASSWORD', 'r7k80f656c73e22901f8e2e4a25e767d99da60164865fe9f8e2e4a25e76sdfwf' );
  1. Wipe existing Wordpress media directory, then extract the backup zip file:
1
2
3
4
cd /bitnami/wordpress/
sudo rm -v -r *
sudo unzip /home/bitnami/bitnami.zip
rm /home/bitnami/bitnami.zip
  1. Swap database user info from wp-config.php with the ones you copied in previous step:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sudo nano /bitnami/wordpress/wp-config.php

/** Database username */

- define( 'DB_USER', 'bn_wordpress' );
+ define( 'DB_USER', 'bn_wordpress' );


/** Database password */
- define( 'DB_PASSWORD', 'qom2slpozozajid2sufochospuca48efiphlf4splfapljustlb4mlw8that1hiq' );
+ define( 'DB_PASSWORD', 'r7k80f656c73e22901f8e2e4a25e767d99da60164865fe9f8e2e4a25e76sdfwf' );
  1. Fix permissions for files and folders
1
2
3
4
5
6
7
8
9
cd /opt/bitnami
sudo chown -R bitnami:daemon wordpress/
sudo find wordpress/ -type d -exec chmod 775 {} \;
sudo find wordpress/ -type f -exec chmod 664 {} \;
cd /bitnami
sudo chown -R bitnami:daemon wordpress/
sudo find wordpress/ -type d -exec chmod 775 {} \;
sudo find wordpress/ -type f -exec chmod 664 {} \;
sudo chmod 640 wordpress/wp-config.php
  1. Swap MySQL/Mariadb database from backup file, and enter MySQL/Mariadb root password when required (located at /home/bitnami/bitnami_credentials)"
1
2
3
4
5
6
mysql -u root -p
mysql> drop database bitnami_wordpress;
mysql> create database bitnami_wordpress;
exit
mysql -u root -p -D bitnami_wordpress < /home/bitnami/mysqldump2023.sql
rm /home/bitnami/mysqldump2023.sql
  1. Update DNS records to point to the new server public IP.

  2. Generate Let’s Encrypt HTTPS certificate:

1
sudo /opt/bitnami/bncert-tool
  1. (Optional) Copy any other custom customizations from old server:
1
2
3
sudo nano /opt/bitnami/php/etc/php.ini
max_execution_time 300
sudo /opt/bitnami/ctlscript.sh restart php-fpm

Congratulations! You have made it. Your site now runs using the latest Bitnami image release.

Video Guide

Built with Hugo
Theme Stack designed by Jimmy