Install Gammu SMS Gateway In Ubuntu

How to Install Gammu SMS Gateway In Ubuntu

In this tutorial will guide how to install Gammu SMS Gateway In Ubuntu Server

Tested On :

----->>Ubuntu Server 12.10 64 Bit
----->>CPU Dual Core, RAM 2GB and HDD 8GB (ATA HDD)
----->> Gammu 1.33.0

A. First we install the package that will be needed :

root@SMSGATEWAY:~# apt-get update
root@SMSGATEWAY:~# apt-get install autoconf gcc make cmake libxml2 libxml2-dev libmysqlclient15-dev mysql-server mysql-client apache2 php5 libapache2-mod-php5
Start apache service :
root@SMSGATEWAY:~# /etc/init.d/apache2 restart
Search php modules and install
root@SMSGATEWAY:~# apt-cache search php5
root@SMSGATEWAY:~# apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
And then after install modules finish, restart apache service
root@SMSGATEWAY:~# /etc/init.d/apache2 restart
Install phpmyadmin (Optional) to easily manage database
root@SMSGATEWAY:~# apt-get install phpmyadmin

B. Download and install Package Gammu

root@SMSGATEWAY:~# wget http://sourceforge.net/projects/gammu/files/gammu/1.33.0/gammu-1.33.0.tar.gz
root@SMSGATEWAY:~# tar xvfz gammu-1.33.0.tar.gz
root@SMSGATEWAY:~# cd gammu-1.33.0/
root@SMSGATEWAY:~/gammu-1.33.0# ./configure
root@SMSGATEWAY:~/gammu-1.33.0# make
root@SMSGATEWAY:~/gammu-1.33.0# make install
root@SMSGATEWAY:~# cd docs/config
root@SMSGATEWAY:~/gammu-1.33.0/docs/config# cp gammurc smsdrc /etc/
root@SMSGATEWAY:~/gammu-1.33.0/docs/config# mkdir /var/log/gammu
root@SMSGATEWAY:~/gammu-1.33.0/docs/config# cd /var/log/gammu
root@SMSGATEWAY:/var/log/gammu# touch smsdlog
root@SMSGATEWAY:/var/log/gammu# dmesg | grep tty
root@SMSGATEWAY:/var/log/gammu# nano /etc/gammurc

[gammu]
port = /dev/ttyUSB0
connection = at115200
root@SMSGATEWAY:/var/log/gammu# nano /etc/smsdrc
[gammu]
port = /dev/ttyUSB0
connection = at115200
logfile = /var/log/gammu/gammu.log

[smsd]
#service = MYSQL
service = SQL
driver = native_mysql
#driver = SQL
logfile = /var/log/gammu/smsdlog
commtimeout = 10
sendtimeout = 10
checksecurity = 0
checksignal = 1

pc = localhost
user = user-database
password = database-password
database = database-name
Create database :
root@SMSGATEWAY:/var/log/gammu# mysql -u database-user -pdatabase-password
root@SMSGATEWAY:/var/log/gammu# create database database-name;
root@SMSGATEWAY:/var/log/gammu# mysql -u database-user -pdatabase-password database-name < database-name.sql
root@SMSGATEWAY:/var/log/gammu# nano /etc/ld.so.conf and add this line :  /usr/local/lib
root@SMSGATEWAY:/var/log/gammu# /sbin/ldconfig
Check modem and you will see details about your modem info:
root@SMSGATEWAY:~# gammu --identify

C. Create and running gammu service :

root@SMSGATEWAY:~# gammu-smsd -c /etc/smsdrc
root@SMSGATEWAY:~# cp gammu-1.33.0/contrib/init/gammu-smsd.rh /etc/init.d/gammusmsd
root@SMSGATEWAY:~# nano /etc/init.d/gammusmsd
And paste line below in file
bin="/usr/local/bin/gammu-smsd"
configfile="/etc/smsdrc"
pidfile="/var/run/gammu.pid"
proc_name=`basename $0`
PID=`cat $pidfile`
function START_CMD {
$bin -c $configfile -p $pidfile -d
if [ "$?" != "0" ];then
echo "ERROR - gammu did not start!"
fi
}
function STATUS {
PID=`cat $pidfile`
if [ -n "$PID" ] ; then
echo "$proc_name running PID: $PID"
else
echo "$proc_name not running"
fi
}
# See how we were called.
case "$1" in
start)
if [ -n "$PID" ]; then
if [ "`ps -p "$PID" -o comm=`" = "" ]; then
START_CMD
STATUS
else
echo "Error - $proc_name already running!"
STATUS
fi
else
START_CMD
STATUS
fi
;;
status)
STATUS
;;

stop)
if [ -n "$PID" ] ; then
echo "$proc_name stopping PID: $PID"
kill $PID
sleep 1
echo "" > $pidfile
echo "$proc_name stopped"
fi
;;
restart|reload)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit
0
And then change permission :
root@SMSGATEWAY:~# chmod +x /etc/init.d/gammusmsd

To be continue for Web base interface to Send/Receive SMS

Congratulations you have successfully created a SMS Gateway

 

Copyright Albenet Hosting Sunday 25-Jun-2017 All rights reserved.