Pre-rquisite:
I will be using Debian 12
Step 1: Install MariaDB
Add MariaDB repository
sudo apt-get install apt-transport-https curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
cat > /etc/apt/sources.list.d/mariadb.sources << EOF
# MariaDB 11.3 repository list - created 2024-04-03 09:50 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/11.3/debian
URIs: https://download.nus.edu.sg/mirror/mariadb/repo/11.3/debian
Suites: bookworm
Components: main
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
EOF
update repository
apt-get update
install MariaDB
apt-get install mariadb-server
Step 2: Configure MariaDB
vim /etc/mysql/mariadb.conf.d/50-server.cnf
vim /etc/mysql/mariadb.conf.d/50-server.cnf
set bind-address to listen to all ports
bind-address = 0.0.0.0
Start MariaDB
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
Enter current password for root (enter for none): Enter
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Reference: https://cloudinfrastructureservices.co.uk/setup-mariadb-replication/
Step 3: Create a Database for MongooseIM
Go to the MongooseIM Github repo and download the latest MonogooseIM
wget https://github.com/esl/MongooseIM/archive/refs/tags/6.2.0.tar.gz
tar -sxvf 6.2.0.tar.gz
Go to Directory priv/
cd MongooseIM-6.2.0/priv
mysql -h localhost -u user -p -e 'create database mongooseim'
mysql -h localhost -u user -p mongooseim < mysql.sql
This would create 40 tables. Now create DB User
mysql -u root -p
Enter password:
MariaDB [(none)]:) create user 'imuser'@'%' identified by 'passw0rd';
MariaDB [(none)]:) grant all on mongooseim.* to 'imuser'@'%';
MariaDB [(none)]:) flush privileges;
MariaDB [(none)]:) exit
Step 4: Compile MonoogseIm from Source
apt install redis
go directory /path/to/mongooseim/tool/
./tools/configure with-mysql with-redis user=root prefix=/opt/ system=yes
make rel
cd _build/prod/rel/mongooseim
apt install redis
go directory /path/to/mongooseim/tool/
./tools/configure with-mysql with-redis user=root prefix=/opt/ system=yes
make rel
cd _build/prod/rel/mongooseim
Reference: https://esl.github.io/MongooseDocs/latest/tutorials/How-to-build/
Step 5: Configure MongooseIM with Mysql
Add the following modules in mongooseim.toml file
[auth]
methods = ["rdbms"]
# methods
[auth.rdbms]
users_number_estimate = true
[outgoing_pools.rdbms.default]
scope = "global"
workers = 10
strategy = "available_worker"
[outgoing_pools.rdbms.default.connection]
driver = "mysql"
host = "localhost"
database = "mongooseim"
username = "imuser"
password = "passw0rd"
#[internal_databases.mnesia]
[outgoing_pools.rdbms.mysql]
scope = "global"
workers = 10
strategy = "available_worker"
[outgoing_pools.rdbms.mysql.connection]
driver = "mysql"
host = "localhost"
database = "mongooseim"
username = "imuser"
password = "passw0rd"
# tls.required = true
# tls.cacertfile = "priv/ssl/cacert.pem"
# tls.server_name_indication.enabled = false
[services.service_mongoose_system_metrics]
[modules.mod_mam]
backend = "rdbms"
[modules.mod_muc]
backend = "rdbms"
[modules.mod_roster]
backend = "rdbms"
versioning = true
store_current_id = true
[modules.mod_auth_token]
backend = "rdbms"
[modules.mod_last]
backend = "rdbms"
[modules.mod_time]
Step 6: Start MongooseIM and Debug
bin/mongooseim start
bin/mongooseimctl status
bin/mongooseim start
bin/mongooseimctl status
in case of an error use the following command for troubleshooting
bin/mongooseimctl foreground
or
bin/mongooseimctl debug
Step 7: Add Users and Send your First IM
Create XMPP User
/opt/imserver/usr/bin/mongooseimctl account registerUser --domain imserver.hbvoice.local --username hamid --password 12345
/opt/imserver/usr/bin/mongooseimctl account registerUser --domain imserver.hbvoice.local --username raza --password 12345
Download pidgin for Windows or Astrachat for Android
Register users in these Apps and try sending IM messages to each other.
Enjoy ;)