How to Upgrade Bitnami Wordpress stack

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.
- If you are using extended firewall in your application such as Wordfence extended protection, it’s recommended to disable this option temporarily.
- SSH to the
old
bitnami server using an SSH client. - Stop all services and start
mysql
ormariadb
to do the database backup:
sudo /opt/bitnami/ctlscript.sh stop
sudo /opt/bitnami/ctlscript.sh start mariadb
sudo /opt/bitnami/ctlscript.sh status
- Execute
mysqldump
command to backup the application database namedbitnami_wordpress
into a file namedmysqldump2023.sql
, and enter MySQL/Mariadb root password (located at/home/bitnami/bitnami_credentials
):
cd /home/bitnami
sudo mysqldump -u root -p bitnami_wordpress > mysqldump2023.sql
- Compress Wordpress main directory while maintaining symlinks:
cd /opt/bitnami/wordpress/
sudo zip -r /home/bitnami/optbitnami.zip * --symlinks
- Compress Wordpress media directory:
cd /bitnami/wordpress/
sudo zip -r /home/bitnami/bitnami.zip *
- Deploy
new
bitnami server from AWS marketplace or Lightsail console. Feel free to change CPU, RAM and disk size if you need to. Upload thenew
instance key filepem
into theold
server’s/home/bitnami
directory. In summary theold
server’s/home/bitnami
directory should have these following 4 files:
cd /home/bitnami
mysqldump2023.sql
optbitnami.zip
bitnami.zip
newkey.pem
- Fix
newkey.pem
key permissions inold
server:
chmod 600 newkey.pem
- Use
scp
to transfer the backup files fromold
tonew
server, where34.228.112.230
representsnew
public server IP address. Sincescp
is an encrypted protocol we are not worried about using the server private IP for file transfer:
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
- SSH to the
new
bitnami server using an SSH client. - Wipe existing Wordpress main directory, then extract the backup zip file:
cd /opt/bitnami/wordpress/
sudo rm -v -r !("optbitnami.zip")
sudo unzip optbitnami.zip
sudo rm optbitnami.zip
- Navigate to Wordpress media directory, and copy database user info from
new
wp-config.php before deletion:
nano /bitnami/wordpress/wp-config.php
/** Database username */
define( 'DB_USER', 'bn_wordpress' );
/** Database password */
define( 'DB_PASSWORD', 'r7k80f656c73e22901f8e2e4a25e767d99da60164865fe9f8e2e4a25e76sdfwf' );
- Wipe existing Wordpress media directory, then extract the backup zip file:
cd /bitnami/wordpress/
sudo rm -v -r *
sudo unzip /home/bitnami/bitnami.zip
rm /home/bitnami/bitnami.zip
- Swap database user info from
wp-config.php
with the ones you copied in previous step:
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' );
- Fix permissions for files and folders
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
- Swap MySQL/Mariadb database from backup file, and enter MySQL/Mariadb root password when required (located at
/home/bitnami/bitnami_credentials
)"
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
Update DNS records to point to the new server public IP.
Generate Let’s Encrypt HTTPS certificate:
sudo /opt/bitnami/bncert-tool
- (Optional) Copy any other custom customizations from
old
server:
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.