Playsms Twilio

Rendy wijaya
6 min readSep 25, 2020

--

Hello There This is me im back to action, ACT! ION!

okay i’ll get you how to setup playsms with twilio
Okay my environment ubuntu VPS Alibaba Aliyun ECS 18.04, PHP 7.2, Mariadb, apache2, Lets Go, Action!
This is my refference from anton itself!
https://playsms.org/2020/03/20/install-playsms-1-4-3-on-ubuntu-18-04/

Login to our ssh vps, im using MobaXterm btw

Create User, dont use root acces
Im using Gateways for name in vps, you can choose whatever its name

always update and upgrade your fresh cloud vps

apt-get update
apt-get upgrade

Keep local version

create a new normal Linux user and set a strong password!

adduser gateways

Add user gateways to sudo group, so user gateways can use sudo, this is important, if skipped you must do extra work later time

usermod -a -G sudo gateways

update your sistem again

apt-get update

Reboot your vps

reboot

Login as user Gateways

Install mc, unzip, git

sudo apt update
sudo apt install mc unzip git

Check software-properties-common, it provides some useful scripts for adding and removing PPAs

dpkg -L software-properties-common | grep 'bin/'

If no installed, install it with

sudo apt-get install software-properties-common

now we can add ppa without opening sources.list

okay from this point we will build webserver environment for playsms

Install MySQL server MariaDB:

sudo apt install mariadb-server

Starts MariaDB and enable it:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Test your MySQL root access:

sudo mysql

You should now logged in to your MySQL server as MySQL user root. Type quit and <Enter> to exit MySQL console. this is just testing if mysql works or not, We will not use MySQL user root in playSMS but we will create a new MySQL user just for playSMS database later but please secure your own mysql with

sudo mysql_secure_installation

Well if this doesnt work like you thought, do this

#Acces Mysql through sudo
sudo mysql -u root
#Delete user root mysql
DROP USER 'root'@'localhost';
#Then Create it again with fresh password
CREATE USER 'root'@'%' IDENTIFIED BY '123456';
#'123456' is password i gave to root
#create privileges to user root so root can CRUD database
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
#Test again mysql
mysql -u root -p
#enter your password
#you've succesfuly make password for root
#Make user and database for playsms
CREATE USER 'playsms'@'localhost' IDENTIFIED BY 'strongpasswordhere';
GRANT ALL PRIVILEGES ON playsms.* TO 'playsms'@'localhost';
FLUSH PRIVILEGES;
quit
#please by any mean, to change you password not strong ...

Install Apache webserver

sudo apt-get install apache2

Test to your public ip or internet ip or domain make sure its apache2 is installed

Next install php 7.2

#Add ondrej/php PPA
sudo add-apt-repository ppa:ondrej/php
#install PHP7.2
sudo apt install php7.2 php7.2-cli php7.2-mysql php7.2-gd php7.2-curl php7.2-mbstring php7.2-xml php7.2-zip
#Test it on /var/www/html
sudo nano /var/www/html/hello.php
<?php
echo "Hello World";
#CTRL X to save then enter enter
#if its work, delete file hello.pphp
cd /var/www/html
sudo rm hello/php

Okay then prepare for playsms installation, in this testing im using sub domain and prepare virtualhost you your own or do this in var/www/html and not use virtual host

The example VirtualHost configuration will make Apache serve PHP file for domain dm13.smsthawaf.xyz from our regular user (user gateways) Home Directory (/home/gateways/public_html to be exact).

cd /home/gateways/
mkdir -p public_html log
sudo chmod 775 /home/gateways public_html log
sudo chown gateways.gateways -R /home/gateways
sudo chown www-data.gateways -R /home/gateways/log
#see ownership folder and file
ls -l /home/gateways
sudo nano /etc/apache2/sites-available/dm13.smsthawaf.xyz.conf
<VirtualHost *:80>
ServerName dm13.smsthawaf.xyzDocumentRoot /home/gateways/public_htmlErrorLog /home/gateways/log/httpd-error.logCustomLog /home/gateways/log/httpd-accesss.log combined<Directory /home/gateways/public_html>AllowOverride FileInfo AuthConfig Limit IndexesOptions MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExecRequire method GET POST OPTIONSphp_admin_value engine On</Directory></VirtualHost>

Enable it:

sudo a2ensite dm13.smsthawaf.xyz
sudo systemctl reload apache2.service

Test our virtual host

nano /home/gateways/public_html/test.php
<?php
echo "<b>Welcome !!</b>";
#open brower and check dm13.... and /test.php
#if works delete again
rm /home/gateways/public_html/test.php

Install CertBot
We will get the SSL certificate from Let’s Encrypt and use certbot to install it on the server.

#install CertBot
sudo apt install python3-certbot-apache
#Run certbot for Apache:
sudo certbot --apache

Install playSMS
Now that we have a working web server with PHP and HTTPS supports, and MySQL server, we can then install playSMS 1.4.4.

From now on you must execute commands as normal Linux user. In this article playSMS will be installed under user komodo as mentioned before.

Prepare Directories
Here are some important directories that need to be ready before playSMS installation:

  • /home/gateways/public_html
  • /home/gateways/log
  • /home/gateways/bin
  • /home/gateways/etc
  • /home/gateways/lib
  • /home/gateways/src

public_html and log is already exists and prepared, they are created as part as VirtualHost configuration. So now we need to create the rest and set proper permission.

Then create directories:

cd /home/gateways
mkdir -p bin etc lib src
sudo chmod 775 bin etc lib src

Prepare log files too, this need to be done so that both web server Apache2 and playSMS daemon have write access to playSMS log files:

cd /home/gateways
sudo touch log/audit.log log/playsms.log
sudo chmod 664 log/audit.log log/playsms.log
sudo chown www-data.gateways -R log
ls -l log

Check PHP Modules Required PHP modules should already be installed. But before proceeding with playSMS installation you need to make sure that required PHP modules are installed:

php -m

Make sure you see at least curl, gd, mbstring, mysqli and xml on the list. If they are not on the list then please install them

Ready to install now that we’ve been completed environment for PlaySms

playSMS source code available on Github, you will need git to get them.

Go to src folder:

cd /home/gateways/src

Get lattest playsms 1.4.4

wget -c "https://github.com/antonraharja/playSMS/archive/master.zip" && unzip master.zip
##We've Downloaded playsms 1.4.4alpha
#go to playsms folder
cd playSMS-master/
cp install.conf.dist install.conf
nano install.conf
#edit install.conf so it looks like this
# INSTALL DATA
# ============
# Please change INSTALL DATA below to suit your system configurations
# Please do not change variable name, you may change only the value
# MySQL database username
DBUSER="playsms"
# MySQL database password
DBPASS="strongpasswordhere"
# MySQL database name
DBNAME="playsms"
# MySQL database host
DBHOST="localhost"
# MySQL database port
DBPORT="3306"
# Web server's user, for example apache2 user by default is www-data
# note: please make sure your web server user
WEBSERVERUSER="www-data"
# Web server's group, for example apache2 group by default is www-data
# note: please make sure your web server group
WEBSERVERGROUP="www-data"
# Path to playSMS extracted source files
PATHSRC="$(pwd)"
# Path to playSMS web files
# note: please make sure your web root path, in this example its /var/www/html
PATHWEB="/home/gateways/public_html/playsms"
# Path to playSMS additional files
PATHLIB="/home/gateways/lib"
# Path to playSMS daemon and other binary files
PATHBIN="/home/gateways/bin"
# Path to playSMS log files
PATHLOG="/home/gateways/log"
# Path to playSMS storage
PATHSTR="/home/gateways/storage"
# Path to playSMS daemon configuration file
# note: this example will create playsmsd.conf in /etc
PATHCONF="/home/gateways/etc"
#save CTRL X

Run Playsms install Scripts

cd /home/gateways/src/playSMS
./install-playsms.sh

Re Check all installation folder

Adjust Config.php

/home/gateways/public_html/config.php

Because we use CertBot, we use ssl and https, so set it to TRUE, if you’re using in local machine use False to avoid using https

Setup SMSC and Gateway Twilio
use this refferences

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response