Contents

The Problem

When I opted to use Bitnami on my instance, it came with three preinstalled services: Apache, PostgreSQL, and MariaDB. The first two pleased me because I planned to use Apache as the web server running Django, and PostgreSQL as my remote database. Since my running instance has limited resources, I had to disable the third service for good. After hours of trial and error, I have devised a solution, which I will now explain to you.

But nonetheless, if you want to disable PostgreSQL and keep MariaDB, this tutorial will be helpful. You just need to manipulate files with 'PostgreSQL' in their names.

The Solution

All the commands and modifications below are performed on a Linux (Debian 11) machine running on Amazon Lightsail instance.

Check the status of the services with this command:

sudo /opt/bitnami/ctlscript.sh status

You should see something like:

apache already running
mariadb already running
postgresql already runnin

To stop the MariaDB service, use the following command:

sudo /opt/bitnami/ctlscript.sh stop mariadb

Bitnami utilizes gonit as a monitoring tool for managing services. To begin, we need to hide MariaDB from gonit. Change the current working directory by typing the following command in the shell:

cd /etc/monit/conf.d/

Gonit utilizes that directory to scan for services to monitor. Enter the following command in the shell:

ls

You should observe something similar to:

apache.conf mariadb.conf postgresql.conf

To exclude the service from Gonit, please type the following command in the shell:

sudo mv mariadb.conf mariadb.conf.disabled

This is not enough because Bitnami still launches the process that is invisible to Gonit, therefore `sudo /opt/bitnami/ctlscript.sh status`  will not report MariaDB as present service, but it will run in the background. Don't you believed? Type this commands, even after a reboot: 

sudo systemctl restart bitnami.service
ps aux | grep mariadb

The last one should show you something like this:

mysql       2262  0.6 10.1 1085400 98732 ?       Sl   16:45   0:00 /opt/bitnami/mariadb/sbin/mysqld --defaults-file=/opt/bitnami/mariadb/conf/my.cnf 
    --basedir=/opt/bitnami/mariadb --datadir=/bitnami/mariadb/data --socket=/opt/bitnami/mariadb/tmp/mysql.sock 
    --pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid
bitnami     2345  0.0  0.0   6240   636 pts/0    S+   16:46   0:00 grep mariadb

It indicates that a MariaDB process is still running in the background but remains undetectable by Bitnami.

To resolve this issue, type the following commands:

cd /
sudo su root
cd root
ls -a

You might see something very similar to this:

.  ..  .bash_history  .bashrc  .profile  .provisioner  .ssh

The directory of interest to us is called '.provisioner', therefore type this:

cd .provisioner && ls

It will likely display something close to this:

configuration.json  platform.json  reciperunner.json  stackconfig.json

To ensure reversibility, change the name of the file using this command:

mv stackconfig.json stackconfig.json.old

Open the 'stackconfig.json.old' file with a text editor and copy to clipboard its contents. The content will be a long, single minified JSON line. To simplify the task, utilize a tool that formats the JSON string, such as the website: 'https://jsoneditoronline.org/'.

Start deleting from:

{
    "additionalFiles": {
        "/opt/bitnami/scripts/libmariadb.sh": {
                                               .
                                               .
                                               .

to:

                                               .
                                               .
                                               . 
    "name": "mariadb",
        branch": "debian-11",
        version": "11.1.2-1",
        tarballUrl": "https://downloads.bitnami.com/files/stacksmith/mariadb-11.1.2-1-linux-amd64-debian-11.tar.gz"
},

Copy the edited content from the tool, minify the JSON (minifier), create a new file in /root/.provisioner/ named 'stackconfig.json,' and paste the minified JSON into it.

Restart the Bitnami service: 

sudo systemctl restart bitnami.service

You are now all set up.