Playsms With HTTP

Rendy wijaya
7 min readSep 28, 2020

Hello, today i will presented you how to Install Playsms under HTTP

This is my Environment Ubuntu 18.04 In AWS Free Tier, Php 7.2, Mariadb-server, apache2

In AWS EC2 Ubuntu fresh installation there is default user named ubuntu, so we will use this user to create environment for system playsms

update and upgrade your sistem for lattest patch and new lib

sudo apt-get update
sudo apt-get upgrade

Create new password if there is no password from your SSH(Secure Shell)

update your sistem again
my recommendation is mixing unique character such as #,@,$,~ and uppercase and lowercase, and number

Sudo passwd ubuntu

Install tools for playsms and our workground

sudo apt-get install unzip git

#Note we using git for retrieve and push project for repository and unzip for decompress playsms

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

dpkg -L software-properties-common | grep 'bin/'
This Means you’ve already installed

If doesnt show anything

sudo apt-get install software-properties-common

#Note Personal Package Archives (PPAs) are software repositories designed for Ubuntu users and are easier to install than other third-party repositories.

Okay now we will build Webserver environment so we can install playsms right to our VPS

First is Apache2 for webserver

sudo apt-get install apache2

Why we using apache2? not nginx, well you can use nginx, its just easier to config apache2 from this experiment

okay then please test it over your public ip vps if you see this

Then its installed correctly

Next we install Mariadb-server

sudo apt-get install mariadb-server

Starts MariaDB and enable it:

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

as per now you’ve installed Mariadb, but keep in mind this is fresh install so you must do some configuration over it, lets secure and delete some unnecessary database

sudo mysql_secure_installation
This What its look like
Example

Well i dont know why, but for me up above configuration doesnt work like i thought to be, so lets do it manually

#lets connet myql through sudo
sudo mysql

Okay check or make sure there is user root mariadb in your database

SELECT User,Host FROM mysql.user;

Oh there he is, we’ve found root in host localhost lets delete it, and make new one so we can access it through normal user ubuntu, another note, this is for fresh install!!

DROP USER 'root'@'localhost';

so we deleted(DROP) user root, lets create it again and giving him strong password

CREATE USER 'root'@'%' IDENTIFIED BY 'yourpassword';

What is meaning behind ‘root’@’%’ ? it means you will creating user root in mysql ‘%’ is ipaddress you prefer connect from, in my case i want to remotely connect from anywhere so i set it to ‘%’ it means from any ipaddress, because of that we must set strong password for root database like first i state in early post

Grant priviliges for user root to any database and root can do anything

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Flush it

FLUSH PRIVILEGES;
quit

and we’re done to set Mariadb lets recheck again using our password

mysql -u root -p

Create database for playsms

create database playsms;
show databases;
quit

now we’re done set it up for mariadb lets continue to php7.2

add PPA Ondrej/php so we can install it easily thanks for Ondřej Surý to maintain this PPA

first add PPA Repository

sudo add-apt-repository ppa:ondrej/php

Update your sistem to recognice new PPA

sudo apt-get update

Install Php7.2 and othe Library requirement

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

thats it, we’ve finish installed PHP7.2 and dependency now test it on apache in /var/www/html

sudo nano /var/www/html/hello.php
<?php
echo "Hello World";
?>

Test it on your browser, if there is nothing wrong, delete hello.php

cd /var/www/html
sudo rm hello/php

Webserver its good to go next some preparation for Playsms

Install playSMS
Now that we have a working web server with PHP 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 Ubuntu

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

  • /var/www/html/playsms
  • /home/ubuntu/log
  • /home/ubuntu/bin
  • /home/ubuntu/etc
  • /home/ubuntu/lib
  • /home/ubuntu/src
  • /home/ubuntu/storage

okay first we will make sure var www is accesible with normal user

sudo chmod 775 -R /var/www/html/

Chmod 775 means (chmod a+rwx,o-w) sets permissions so that, (U)ser / owner can read, can write and can execute. (G)roup can read, can write and can execute. (O)thers can read, can’t write and can execute. -R is Recursive so the children also have thats trait

change Ownership for var www html

sudo chown ubuntu.ubuntu -R /var/www/html

test it from normal user

nano /var/www/html/testownership.html

okay if succes delete again,now we move to home/ubuntu folder

cd /home/ubuntu

Create above directory

mkdir -p bin etc lib src log storage

Change ownership for folder

sudo chown ubuntu.ubuntu -R /home/ubuntu

give www-data to log

sudo chown www-data.ubuntu -R /home/ubuntu/log

www-data is the user that web servers on Ubuntu (Apache, nginx, for example) use by default for normal operation. The web server process can access any file that www-data can access.

Re check Ownership

ls -l /home/ubuntu
Looks like this

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/ubuntu/
sudo touch log/audit.log log/playsms.log
sudo chmod 664 log/audit.log log/playsms.log
sudo chown www-data.ubuntu -R log
ls -l log

Okay now all environment is clear and steady for lets recheck module php we need to install playsms

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/ubuntu/src

Get lattest playsms 1.4.4

wget -c “https://github.com/antonraharja/playSMS/archive/master.zip" && unzip master.zip

We’ve Downloaded lattest playsms, go to folder playsms master

cd playSMS-master/

Copy cp install.conf.dist to install.conf

cp install.conf.dist install.conf

Lets edit some configuration matching environment we build

nano install.conf

Make sure content just like this if you use this post

# 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="root"
# MySQL database password
DBPASS="yourpassword"
# 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)"
# 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="/var/www/html/playsms"
# Path to playSMS additional files
PATHLIB="/home/ubuntu/lib"
# Path to playSMS daemon and other binary files
PATHBIN="/home/ubuntu/bin"
# Path to playSMS log files
PATHLOG="/home/ubuntu/log"
# Path to playSMS storage
PATHSTR="/home/ubuntu/storage"
# Path to playSMS daemon configuration file
# note: this example will create playsmsd.conf in /etc
PATHCONF="/home/ubuntu/etc"
# END OF INSTALL DATA
# ===================

then install it without using sudo

./install-playsms.sh

if already correct press y then enter

check whether Playsmsd running daemon or not with this

home/ubuntu/bin/playsmsd /home/ubuntu/etc/playsmsd.conf check

to start or stop daemon just replace check to start stop or restart, if its running well you shoul see like this

By default playsms using https config so turn off, if you doesnt use it
in web config.php

nano /var/www/html/playsms/config.php

lets login to playsms by default login playsms is

User:admin
password:changemeplease

Don’t worry if there is red label in log daemon its just wrong path let make it right path

Change config.php in playsmslog

nano /var/www/html/playsms/plugin/feature/playsmslog/config.php

change bin and conf so it looks like this

Change Plasysms password and set Twilio like this tutorial and we’re done

https://playsms.org/2020/04/30/gateway-plugin-twilio/

--

--