PlaySMS Install Guide for Debian 11
PlaySMS is an open source SMS management system. It can be used as an SMS gateway, bulk SMS provider, personal messaging system, and for corporate and group communications.
It has built in gateway connectivity to various providers such as Twilio, Nexmo, BulkSMS, Clickatell, Infobip, RouteSMS etc. It also has a generic plugin that can be adapted to work with other providers.
Our changes from the original repository are shown at the following link.
https://github.com/playsms/playsms/compare/master...powerpbx:playsms:master
We have created a custom gateway for Telnyx.
Tested using the following software:
- Debian 11 (Bullseye) x64 minimal install
- PlaySMS 1.5
- Apache 2.4
- PHP 8.1
- MariaDB 10
Prerequisites
Verify locale is set to C.UTF-8
or en US.UTF-8
.
locale
If it is not then set it now. You may also set your own UTF-8 locale.
# Select C.UTF-8 UTF-8
apt update && apt -y install locales && dpkg-reconfigure locales
Log out/in or close/open shell for changes to take effect.
Install some basics
Ensure a basic server install with intial dependencies to start with.
apt update && apt -y upgrade
apt -y install nano git dbus sudo wget curl dirmngr openssl ntp dnsutils mariadb-client mariadb-server postfix gettext apache2
Postfix
If a postfix configuration wizard pops up you can select the default Internet Site
and also the default mail name. These settings can be manually changed later in /etc/postfix/main.cf
.
## FIND YOUR TIMEZONE tzselect
## SET TIMEZONE EXAMPLE timedatectl set-timezone America/Vancouver
systemctl restart rsyslog timedatectl status
PHP
Install repository
# install this section one line at a time. apt -y install gnupg2 apt-transport-https ca-certificates software-properties-common wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
Install PHP v8.1
apt update && apt -y install php8.1 php8.1-opcache php8.1-cli php8.1-mysqli php8.1-gd php8.1-mbstring php8.1-xml php8.1-curl php8.1-zip php8.1-fpm
update-alternatives --set php /usr/bin/php8.1
Configure Apache
cat >> /etc/apache2/sites-available/playsms.conf << EOF <VirtualHost *:443> ServerAdmin webmaster@localhost ServerName playsms.somedomain.com # ServerAlias www.playsms.somedomain.com DocumentRoot /var/www/playsms SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost> <Directory /var/www/playsms> Options SymLinksIfOwnerMatch Indexes DirectoryIndex index.php Require all granted </Directory> <Directory /var/www/storage> Require all denied </Directory> EOF
Enable website
a2dissite 000-default.conf a2dissite default-ssl.conf a2ensite playsms.conf a2enmod proxy_fcgi ssl a2enconf php8.1-fpm systemctl restart php8.1-fpm systemctl restart apache2
Install PlaySMS
cd /usr/src git clone -b master https://github.com/powerpbx/playsms.git cd playsms
DBPASS=somepassword
mysqladmin create playsms mysql -e "GRANT ALL PRIVILEGES ON playsms.* TO 'playsms'@'localhost' IDENTIFIED BY '${DBPASS}';" mysql -e "flush privileges;"
SERVER_IP=$(ifconfig | sed -En 's/127.0.0.*//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1 | cut -d " " -f1) echo $SERVER_IP
cat >> /usr/src/playsms/install.conf << EOF ADMINPASSWORD="admin" DBUSER="playsms" DBPASS="${DBPASS}" DBNAME="playsms" DBHOST="localhost" DBPORT="3306" URLWEB="https://${SERVER_IP}" PATHSRC="/usr/src/playsms" PATHWEB="/var/www/playsms" PATHBIN="/usr/local/bin" PATHLOG="/var/log/playsms" PATHSTR="/var/www/storage" PATHSRC="$(pwd)" EOF
Check configuration before running script and modify as necessary.
nano /usr/src/playsms/install.conf
Run PlaySMS install script and answer y
to all questions
/usr/src/playsms/install.sh
Create systemd file
cat >> /etc/systemd/system/playsms.service << EOF [Unit] Description=playsms After=mariadb.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/local/bin/playsmsd start ExecStop=/usr/local/bin/playsmsd stop User=www-data Group=www-data [Install] WantedBy=multi-user.target EOF
chmod 755 /usr/local/bin/playsmsd systemctl daemon-reload systemctl enable playsms systemctl restart playsms systemctl status playsms
Post Install
Set ownership and permissions
Run this any time there are any changes/moves/adds/upgrades or if experiencing problems.
# Set owner and group to www-data chown -R www-data. /var/log/playsms /var/www # Directory permissions to 755 (u=rwx,g=rx,o='rx') find /var/log/playsms -type d -exec chmod 755 {} \; find /var/www -type d -exec chmod 755 {} \; # File permissions to 644 (u=rw,g=r,o=r) find /var/log/playsms -type f -exec chmod 644 {} \; find /var/www -type f -exec chmod 644 {} \;
apt -y install firewalld
firewall-cmd --permanent --zone=public --add-service={http,https} firewall-cmd --reload firewall-cmd --list-all
Lock down DB
mysql_secure_installation
Answer Y
to everything.
Login
browse to https://x.x.x.x
username: admin
password: admin
Browse to My account > Preferences
and change password
Optional
Optimize PHP-FPM
sed -i "s/;request_terminate_timeout = 0/request_terminate_timeout = 300/" /etc/php/8.1/fpm/pool.d/www.conf sed -i "s/max_execution_time = 30/max_execution_time = 60/" /etc/php/8.1/fpm/php.ini sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 20M/" /etc/php/8.1/fpm/php.ini sed -i "s/post_max_size = 8M/post_max_size = 20M/" /etc/php/8.1/fpm/php.ini sed -i "s/memory_limit = 128M/memory_limit = 512M/" /etc/php/8.1/fpm/php.ini
systemctl restart php8.1-fpm
Setup SSL Certificate
This assumes you already have some domain or subdomain pointed at the server IP address. For example, playsms.somedomain.com
.
Edit the playsms.conf
to remove the port 443 virtualhost and add a port 80 virtualhost. So the new playsms.conf
should look like the following
cat >> /etc/apache2/sites-available/playsms.conf << EOF <VirtualHost *:80> ServerName playsms.somedomain.com DocumentRoot /var/www/playsms </VirtualHost> <Directory /var/www/playsms> Options SymLinksIfOwnerMatch Indexes DirectoryIndex index.php Require all granted </Directory> <Directory /var/www/storage> Require all denied </Directory> EOF
systemctl reload apache2
Install certbot and get letsencrypt certificate
apt install certbot python3-certbot-apache certbot --apache -d playsms.somedomain.com systemctl reload apache2
Update the web url if necessary
nano /var/www/playsms/appsetup.php
$core_config['http_path']['base'] = 'https://playsms.somedomain.com';
Test automatic renewal.
certbot renew --dry-run
Set up the automatic renewal routine to run weekly.
crontab -e
0 0 * * 0 root /usr/bin/certbot renew >/dev/null 2>&1
Disable Captcha
Captcha can be disabled at storage/application/plugin/core/auth/config.php
.
Adding Additional Gateways
Most gateways are not installed by default and are located in /usr/src/playsms/storage/application/plugin/gateway
The generic gateway can be used as a basis for creating a new gateway for some other provider.
Troubleshooting
To show all errors in /var/log/apache2/error.log
, go to storage/custom/application/configs/config.php
and uncomment
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
For verbose run time logging to /var/log/playsms/playsms.log
, change the following setting just below the above one.
$core_config['logstate'] = 4;