You are on page 1of 48

Tutorial

Build Your Own SMS Server

vaio
[Type the company name]
SMS
Build Your Own SMS Server SMS

BUILDING YOUR OWN SMS SERVER


[ LINUX FEDORA 9, GNOKII,PHP,MYSQL,PHP,CAKEPHP,APACHE ]

About Me

Here’s a brief about me. My name is Azril Nazli and I’m from Malaysia. Met Linux since
1995 and never stopped loving it since then. Started web programming back in 1999
when PHP3 was introduced and now I’m still developing using CakePHP Framework.
Apart from this SMS Project, I manage a wifi controller using open source tools.
http://mamakspot.blogspot.com

Basic Knowledge To Follow This Tutorial

Linux, Vi Text Editor, Web Programming basic and able to follow visual tutorial and able
to troubleshoot by yourself and able to use Google
Build Your Own SMS Server SMS

INTRODUCTION
In this tutorial, we will build a SMS system using your own computer and normal mobile
phone. The goal of this tutorial is, to use a web based system for sending and receiving
SMS.

Hardwares used

1. Sony VAIO-VGN CR11GH Notebook


2. Sony W980 Mobile Phone
3. USB Cable connecting the phone to notebook ( comes with the phone )

Softwares used

1. Windows VISTA Home Edition


2. VMWARE Server 1.0.8
3. Linux Fedora 9 Live ISO
4. Gnokii SMSD
5. MySQL Database
6. PHP 5.2 Server
7. CakePHP 1.2 Framework
8. Apache 2 Server
Build Your Own SMS Server SMS

1. Go to http://www.vmware.com and download free VMWARE 1.0.8 server


URL : http://register.vmware.com/content/download-108.html
Download both files , VMware Server for Windows OS and VMware Server
Windows client package.
Build Your Own SMS Server SMS

Choose Custom Installation

Only install VMware


Build Your Own SMS Server SMS
Build Your Own SMS Server SMS
Build Your Own SMS Server SMS
Build Your Own SMS Server SMS
Build Your Own SMS Server SMS
Build Your Own SMS Server SMS
Build Your Own SMS Server SMS

In this case, I only use 2GB of disk space


Build Your Own SMS Server SMS

Now we want to boot using Fedora 9 Live CD ISO. Click Edit virtual machine settings
Build Your Own SMS Server SMS

Select CD-ROM and choose Use ISO image. Then Click browse and point to your Linux Fedora ISO image.
Build Your Own SMS Server SMS

Click “Install to Hard Drive “ icon


Build Your Own SMS Server SMS

Choose DHCP for eth0


Build Your Own SMS Server SMS

Set your Root password


Build Your Own SMS Server SMS
The image cannot be display ed. Your computer may not hav e enough memory to open the image, or the image may hav e been corrupted. Restart y our computer, and then open the file again. If the red x still appears, y ou may hav e to delete the image and then insert it again.

Click Yes
Build Your Own SMS Server SMS

Click write changes to disk


Build Your Own SMS Server SMS

Install Fedora 9 into VMWARE Hard Disk we created earlier.


Build Your Own SMS Server SMS

TURNING OFF X WINDOWS SYSTEM.

Restart back the system and login as root ( Choose Other in login window ).

I will not use X Windows since it will use a lot of memory. So to turn off X Windows server, using Shell
Terminal, edit this file /etc/inittab. Change the defaut value from 5 to 3 as shown above. Save the file and
restart the system.
Build Your Own SMS Server SMS

After you restarting the server, login as root and type this command to check your assigned ip address via
DHCP.

Ifconfig eth0

On the example shown above, the ip address is located at 10.1.10.107.


Build Your Own SMS Server SMS

To enable you connect the the system using WinSCP or FileZilla Secure FTP, turn off IPTABLES service and
turn on SSHD service. Issue these command

service iptables stop [ENTER]

service sshd start [ENTER]

Example is shown above.


Build Your Own SMS Server SMS

Gnokii 0.6 is already installed by default in Linux Fedora 9 distribution. But we need to install Gnokii
SMSD. Issue this command

yum install gnokii-smsd [ENTER]

Then the system will automatically find gnokii-smsd on Linux Fedora Repo server. Choose Y
Build Your Own SMS Server SMS

Next we need to install Gnokii SMSD MySQL. We will using MySQL database to store incoming SMS and
using MySQL to send outgoing SMS. Issue this command

yum install gnokii-smsd-mysql [ENTER]

Above screenshot will be displayed, Choose Y to install.

Till now, you have already installed 2 application. What needed till now is

[root@localhost ~]# rpm -qa | grep gnokii

gnokii-0.6.24-1.fc9.i386

gnokii-smsd-mysql-0.6.24-1.fc9.i386

gnokii-smsd-0.6.24-1.fc9.i386
Build Your Own SMS Server SMS

We need MySQL Server for database storage. Issue this command

yum install mysql-server [ENTER]

Choose Y to install
Build Your Own SMS Server SMS

Fedora 9 doesn’t comes with PHP as default, so we need to install PHP. Issute this command

yum install php [ENTER]


Build Your Own SMS Server SMS

We will need PHP-MySQL extension to store the data from PHP. Isse this command

yum install php-mysql [ENTER]


Build Your Own SMS Server SMS

We need to allow execution of .htaccess in /var/www/html folder since we will use CakePHP for our
FrameWork.

I use FileZilla to access my system located at 10.1.10.107. After logged in, go to /etc/httpd/conf/ and edit
this file httpd.conf. I use Crimson Text Editor for editing.

Change line 292 from AllowOverride None to AllowOverride All

And line 328 from AllowOverride None to AllowOverride All

Save the file.


Build Your Own SMS Server SMS

After you saved the file, FileZilla ftp will ask for confirmation. Click OK.

We have installed PHP and MySQL. Now we need to run them using service command.

service httpd start [ENTER]

service mysqld start [ENTER]


Build Your Own SMS Server SMS

We need to install wget to download files for the internet using wget. Issue this command

yum install wget [ENTER]

Go to http://www.cakephp.org and download CakePHP 1.2.0 RC3 and place it on /var/www/ folder. You
either download using Windows and transfer to Fedora using FileZilla SFTP or use wget directly in the
console.
Build Your Own SMS Server SMS

I use wget to download cakephp 1.2.0 RC3 and rename it as cakephp.tar.gz. Extract it using this command

tar zxvf cakephp.tar.gz

Then I rename html folder as html.ori . After that I rename cakephp_1_2_0 folder as html as shown
below.
Build Your Own SMS Server SMS

Now point you browser to you IP ADDRESS. In this case I use http://10.1.10.107 and CakePHP is
successfully installed on my system.
Build Your Own SMS Server SMS

We are going to add USB support to the system since I’m using Sony W980 mobile phone attacted to my
laptop via USB. Click Edit Virtual Machine Setting and you’ll presented by the menu shown above. Click
Add and choose USB Controller
Build Your Own SMS Server SMS

Choose USB Controller and click Next.

Then power on back the system. Don’t forget to connect your phone in ‘Phone Mode’.
Build Your Own SMS Server SMS

In this session, we are going to detect mobile phone interface in Linux environment. Make sure you’ve
have already installed your phone driver in Windows. In this case, I’ve already installed Sony W980 driver
in Windows XP. First make sure you’ve already connected your mobile phone in ‘Phone Mode’. Then, click
VM -> Removable Devices -> USB devices -> [ Choose You Mobile Phone Type Here ]
Build Your Own SMS Server SMS

Then in Linux console, type this command

dmesg

After typing the command, you’ll presented by output shown above.

cdc_acm 1-1:3.1: ttyACM0: USB ACM device

cdc_acm 1-1:3.3: ttyACM1: USB ACM device


Build Your Own SMS Server SMS

Now edit this file either using VI text editor or SFTP into the server and edit using your favorite text editor

File location: /etc/gnokiirc

Change line 11 to your phone interface. In my case is /dev/ttyACM1

Then move to line 52. Change the model to AT

Save the file.


Build Your Own SMS Server SMS

Now we want to test the mobile phone connection. Run this command :

gnokii –identify

In my case, gnokii is able to detect my phone at /dev/ttyACM1 . If your system can’t detect the phone, try
change the port setting in /etc/gnokiirc file and start the test again.

Now for further testing, I send a text message to this number 0146412911 ( which is my other phone
number )

echo ‘Hello World’ | gnokii –sendsms < insert your other mobile phone number > [ENTER]

Example is shown above.


Build Your Own SMS Server SMS

Now use you VM terminal and type the following command

1. cd /usr/share/doc/gnokii-smsd-mysql-0.6.24/
2. ls –l

Command #1 is to enter the directory. Command #2 is to list the file inside the directory. We are going to
create a database and populate the table inside the file above, sms.tables.mysql.sql
Build Your Own SMS Server SMS

Step 1 : create smsdb database

Step 2: import the table structure in sms.tables.mysql.sql file into the smsdb table

Step 3: log into the mysql database console and use smsdb database

Step 4: show the tables inside the smsdb database

1. mysqladmin –uroot create smsdb

2. mysql –uroot smsdb < sms.tables.mysql.sql

3. mysql –uroot smsdb

4. show tables;

5. exit;
Build Your Own SMS Server SMS

Now we’re going to use CakePHP to manage the smsd database.

Rename this file /var/www/html/app/config/database.default.php to


/var/www/html/app/config/database.default.php and the change the login & database value.

Edit line 7 and change login value to ‘root’ and line 9 change database value to ‘smsd’

Save the file.

Edir core.php in the same directory and change line 153 to something else.
Build Your Own SMS Server SMS

Change the folder permission for /var/www/html/app/tmp to 777

Example if using command line in Linux shell.

Now open back the web server, in my case the server IP located at http://192.168.1.4

You should be able to see the message above. That means, you are ready to write the next application.
Build Your Own SMS Server SMS

We are going to create database model for table inbox and table outbox. First, create a file named
inbox.php inside /var/www/html/app/models folder. And paste the following code.

Save the file as inbox.php inside the /var/www/html/app/models folder.

Then repeat the same process again for outbox.php. Paste the following code.

Save the file as outbox.php inside the /var/www/html/app/models folder.


Build Your Own SMS Server SMS

Next, we are going to create the controllers for Inbox and Outbox models. First, go to this folder
/var/www/html/app/controllers and create this file, inboxes_controller.php and paste the following
code.

Paste the code above and save as inboxes_controller.php inside /var/www/html/app/controllers folder.

Paste the code above and save as outboxes_controller.php inside /var/www/html/app/controllers


folder.
Build Your Own SMS Server SMS

Inboxes is where incoming SMS will be saved

Now it is time to test the interface. Using your windows XP browser, go to http://<your VM IP
Address>/inboxes. In this case my VM ip address is located at http://192.168.1.4/inboxes .

Outbox is where outgoing SMS will be sent

Now it is time to test the interface. Using your windows XP browser, go to http://<your VM IP
Address>/outboxes. In this case my VM ip address is located at http://192.168.1.4/outboxes.
Build Your Own SMS Server SMS

Now it is time to run the SMS Daemon. This daemon will connect to mysql database and the the tables for
incoming and outgoing messages. Run this command

gnokii-smsd –u root –d smsdb –c localhost –m mysql

Then try send a SMS to the connected phone and check your Inboxes database data using the web
browser.

If there’s no incoming data, probably you’ll need to tell gnokii-smsd to read the SMS from the PHONE
MEMORY. So just issue the following command.

gnokii-smsd –u root –d smsdb –c localhost –m mysql –b ME

To check your memory status you can use this command

gnokii --showsmsfolderstatus
Build Your Own SMS Server SMS

Here is the sample of my inboxes table. All the incoming SMS will stored directly into the database.

This is a sample how outgoing SMS inside the Outboxes databases. Just click New Outbox and only enter
Number and Text then hit Submit.

Now you have a working SMS System. To take this system further, you might need to learn some PHP
programming by harnessing the CakePHP power. Learn CakePHP at http://www.cakephp.org

You might also like