Setup and Install OpenVBX on Cloud & Integrate Twilio Client • sinxLoud

sinxLoud
14 min readAug 6, 2018

--

Get Started With OpenVBX in minutes, not days !

Call Tracking can enable any company to increase sales calls, improve phone call revenue and optimize the marketing mix through clearer attribution. Phone tracking platforms are important to digital marketing for industries that rely on phone calls as well as form submissions.

Image Source: openvbx.org

This article focuses on open-sourced Call tracking software called OpenVBX to track online and traditional advertising. Know which ads are working, which agents are performing, and make the most of every call.

I’m going to keep it simple so that anyone, whether freelancer or business owner can follow instructions to install OpenVBX on Cloud and Integrate Twilio Client with OpenVBX so that you or your employees can receive and make outbound calls from the browser at any time.

So, today we’re going to take a look at how to Setup OpenVBX on Google Cloud, configure OpenSource SSL, and enable essential services through Debian CLI to keep Instance streamlined to run OpenVBX. Please review the checklist below and Installing OpenVBX will be easy by following our guide:

I am using Google Cloud to set up an instance, running Debian 8 (Jessie) Highly Recommended. I have setup OpenVBX on other Linux distributions and I can confidently say that OpenVBX Installation on Debian 8 (Jessie) is much easier compared to other Linux distribution or instances running on any other cloud service like AWS or DigitalOcean. Also, know that you can get $300 Credit to try Google Cloud Platform Services. view details

1. Setup an Instance on Google Cloud

Follow the Instructions below to deploy an instance on Google Cloud Platform;

Step 1. Create New Project In Google Cloud Platform

Once you’ve signed up for Trial or purchased Google Cloud, you’ll need to log into your Google account and access the Google Cloud Console. From the Project drop-down, click Create project:

Create a Google Cloud Project

Step 2. Navigate to Compute Engine

Google Compute Engine offers high-performance virtual machines, customer-friendly pricing, fast networking, and carbon-neutral impact.

Go to VM Instances

Google Compute Engine offers high-performance virtual machines

Step 3. Create an Instance

Click, Create Instance

  • Enter Deployment Name — Deployment name can only contain lowercase characters, numbers or dashes. It must start with a lowercase letter and cannot end with a dash.
  • Select Zone — The zone determines what computing resources are available and where your data is stored and used Learn more
  • Configure Machine Type — Machine types determine the specifications of your machines, such as the amount of memory, virtual cores, and persistent disk limits an instance will have. Learn more about machine types
  • Boot Disk Type — Change to Debian 8 (Jessie)Storage space is much less expensive for a standard persistent disk. An SSD persistent disk is better for random IOPS or streaming throughput with low latency. Learn more
  • Firewall — By default, all incoming traffic from outside a network is blocked. Select the type of network traffic you want to allow. Learn more Check both Allow HTTP & HTTPS Traffic.
  • Finally, Click on Create and Wait for Google to generate an IP Address and provide SSH Access.

Follow the instructions below to ensure that successfully create an instance.

Create a Virtual Machine Instance using a Boot Disk Image

Step 4. Change Boot Disk to Debian 8 (Jessie)

Debian is a Unix-like computer operating system that is composed entirely of free software, and packaged by a group of individuals participating in the Debian Project. read more

Debian is for People who don’t want to be Noobs.

Step 4. Finally, Create

Scroll down to Click on Create and Wait for Google to generate an IP Address and provide you SSH link to access Terminal.

Review Instance Configuration to Continue.

Step 5. Launch Terminal

Click on SSH to Launch Terminal so that we get our hands dirty on CLI.

SSH from the Browser allows you to use SSH to connect to a Google Compute Engine virtual machine instance

2. Install LAMP stack on Debian

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. We have already set up a virtual private server that is running Debian, the Linux part is taken care of.

Here is how to install the Apache2 Web Server, MySQL 5 Database, PHP 5 and other important packages and extensions required to install and configure OpenVBX.

Step 1. Update the System

Before running through the steps of this tutorial, make sure that all of your repositories are up to date.

Update your package lists, Type the following command in Terminal:

sudo apt update
Your operating system will compare the software packages currently installed with any new versions that might have been updated recently in the Debian online repositories

Next, Update Your system by typing this command:

sudo apt upgrade
This may take a while, depending on the current version of the operating system you have installed, software packages, and network conditions. On a fresh Server, it will take a few minutes.

Once done, however, the Server is fully patched, updated, and ready for LAMP installation.

Step 2. Install Apache

The next step in LAMP installation is installing the Apache web server. This is a popular web server that allows your server to display web content.

To install Apache, type the following:

sudo apt install apache2
This command installs the basic Apache web server package as well as the documentation that goes along with it.

Once done, type the IP address provided by Google for your server in the browser.

(Example IP Address)
http://111.111.111.111

You will see the default Apache 2 web page, similar to this:

When you are done looking at this test page, please remove it by typing the following command:

sudo rm /var/www/html/info.html

Step 3. Install and Secure MySQL 5+

The next component of the LAMP server is MySQL. This relational database software is an essential backend component for OpenVBX.

Note: OpenVBX does not support the latest Version of MySQL.

To install MySQL, type the following:

sudo apt install mysql-server

Know that the installation routine will ask you to setup a new password for the root MySQL user:

After this, the MySQL installation is finished.

To keep your new database server safe and secure MySQL Installation, type the following:

sudo mysql_secure_installation

At this point, the system will prompt you to enter the password for the root MySQL account. Go ahead and enter the password for the root MySQL account and then the system will then ask you:

Change the root password? [Y/n] n

Since we already set the root MySQL password at our installation, you can say no at this point. The script will ask you to remove any anonymous user’s. Go ahead and answer yes to remove the anonymous user’s option for safety:

Remove anonymous users? [Y/n] y

Next, the script will ask you to either allow or disallow remote logins for the root account. Go ahead and answer yes to remove the disallow remote logins for root for safety:

Disallow remote login? [Y/n] y

Finally, the script will ask you to remove the test database and then reload the privilege tables. Answer yes to both of these. This will remove the test database and process the security changes.

Remove test databases? [Y/n] y

If everything is correct, once done, the script will return with:

All done! If you have completed all of the above steps, your MySQL installation should

All done! If you have completed all of the above steps, your MySQL installation should be completed. Let’s double-check that our new MySQL server is running. Type this command:

mysql -u root -p

Enter the root password you set up for MySQL when you installed the software package. Once in, the following to get the server status, version information and more:

status

This is a good way to ensure that you’ve installed MySQL and are ready for further configuration.

Install MySQL Extension for PHP.

To Install MySQL Extension for PHP Support, type the following:

sudo apt install php5-mysql

Restart Apache Server

sudo service apache2 restart

Create User and Database for OpenVBX

To create a MySQL database and user for OpenVBX, follow these steps:

  • At the command line, type the following:
mysql -u root -p
  • Type the MySQL root password, and then press Enter.
  • To create a database user, type the following command. Replace exampleuser with the user you want to create, and replace examplepasswd with the user’s password:
GRANT ALL PRIVILEGES ON *.* TO 'exampleuser'@'localhost' IDENTIFIED BY 'examplepasswd';

This command will create and grant the user all permissions. However, you can grant specific permissions to maintain precise control over database access.

To learn more about setting up database permissions, click here.

  • To explicitly grant the SELECT permission, type the following command:
GRANT SELECT ON *.* TO 'exampleuser'@'localhost';
  • To create a database, Replace dbexample with the name of the database that you want to create, type the following command:
CREATE DATABASE dbexample;
  • When you are finished create Database, exit the application by typing either of the following commands:
\q

or

exit

Step 4. Install PHP 5

For our last component in LAMP Stack, we will set up and install PHP. The widely-used server-side scripting language used far and wide for dynamic web content, making it essential to many web and application developers. Installing this on your Server is quite easy.

To install PHP, simply type the following command :

sudo apt install php5

Agree to the installation and PHP 5 will be installed on your Server.

Restart Apache Server

sudo service apache2 restart

Now, let’s take a moment to test the PHP software that you just installed. Move into your public web directory:

cd /var/www/html

Once there, use the text editor to create a file named info.php by typing the following command:

sudo vim info.php

This command will use the command line editor vi to open a new blank file with this name. Inside this file, type the following:

Note: You can also type : set paste in vim before you paste to disable automated indenting.

:

Type Set Paste

set paste

Insert paste by typing the following:

i

Inside this file, copy paste the following:

<?php phpinfo(); ?>

Save your changes by entering:

:wq!

Once done, open your web browser and type the IP address provided by Google for your server in the browser.

(Example IP Address) 
http://111.111.111.111/info.php

You will see the default PHP information page, similar to this:

When you are done looking at this test PHP page, please remove it for security by typing the following command:

sudo rm /var/www/html/info.php

Answer Yes when the system will ask you if you wish to remove the test file that you’ve created. you’re finished; you have completed the basic PHP installation.

Install PHP 5 Curl

cURL is a library that lets you make HTTP requests in PHP. It’s required for OpenVBX installation and you can install Curl for PHP 5 by typing the following command in terminal:

sudo apt install php5-curl

Restart Apache Server

sudo service apache2 restart

Once done, you have completed the PHP installation requirements for OpenVBX.

Step 5. Install Git

We need Git to clone OpenVBX from GitHub, CertBot SSL and other package required Setup and configure OpenVBX on your Server. Install Git via Package Installer on your Server by typing the following command:

sudo apt install git

3. Install OpenVBX

Installing OpenVBX is quick and easy but can become very hectic if you don’t follow the instructions carefully.

Step 1. Clone OpenVBX from Github

You can directly clone OpenVBX package on your Instance from Github by running the following command.

sudo git clone https://github.com/twilio/OpenVBX.git

Once the package is successfully downloaded. Move or copy the package to the default root folder of the web server (/var/www/html/) by typing the following command.

sudo cp -R OpenVBX/* /var/www/html/

Now we need to verify if the .htaccess file was created by entering the following command in the terminal. Go to default root folder by typing:

cd /var/www/html/

Type the following command:

sudo cat .htaccess

If the output returns an error message. Go ahead and create .htaccess in the root folder /var/www/html/ by typing the following command:

sudo vim .htaccesss

Copy Paste the code for the .htaccess file in the text editor from OpenVBX repository on GitHub or the Code below:

<IfModule mod_alias.c>
# by default disallow access to the base git folder
RedirectMatch /\.git(/|$) /404
</IfModule>
# cache images for a while
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
# compress output if we can
<IfModule mod_deflate.c>
# Set output filter for zipping content
SetOutputFilter DEFLATE
# Netscape 4.x and 4.06-4.08 have issues
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE can be an issue, for now catch all MSIE
BrowserMatch \bMSIE[56] !no-gzip !gzip-only-text/html
# Exclude file types from compression
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|pdf|zip|tar|rar|gz|dmg|mp3|mp4|m4a|m4p|mov|mpe?g|qt|swf)$ no-gzip dont-vary
# Make sure proxy servers deliver what they're given
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine ON
# Set this if you have your installation in a subdirectory
# RewriteBase /openvbx
# By default always use SSL
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?vbxsite=$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L,QSA]
#RewriteRule ^(.*) index.php/$1 [L,QSA]
ErrorDocument 404 /fallback/rewrite.php
</IfModule>

Restart Apache Server

sudo service apache2 restart

Once done, open your web browser and type the IP address provided by Google for your server in the browser.

(Example IP Address) http://111.111.111.111

You will see the default OpenVBX Check Server Page, similar to this:

Step 2. Change the Permissions for Files.

Change the permission for the following files for passing the server Test by typing:

sudo chmod 777 –Rf /var/www/html/calls/OpenVBX/configsudo chmod 777 –Rf /var/www/html/calls/OpenVBX/audio-uploads

Now it’s time to customize your server.

Step 3. Update Domain’s IP Address for Forwarding

Furthermore, Login to your Domain Control Panel, Navigate to DNS Zone and update the IP Address for forwarding in 3 simple steps.

  1. Host Name — Enter the host name the A record links to. Type @ to point the record directly to your domain name, including the www.
  2. Points to IP Address — Enter 111.111.111.111 (Example)
  3. TTL — Select how long the server should cache the information.

Note: It should take a few minutes for DNS to propagate. However, you can expect a propagation time up to 24 hours. This is because it takes time for the DNS to take effect across the internet. Make use of DNSChecker to check DNS data collected from all location for confirming that your domain is completely propagated or not worldwide.

Once done, open your web browser and type the URL pointed to the IP Address provided by Google for your server in the browser.

(Example Domain) 
http://openvbx.sinxloud.com

You will see the default OpenVBX Check Server Page with all Tests passed, similar to this:

Step 4. Connect MySQL Database

I highly recommend running OpenVBX Installer from the domain name, so that we can later set up an OpenSource SSL for the domain name from the terminal, to keep all the connections secure and prevent unauthorized access. For now, you will need MySQL Database credentials to complete this step.

Click Next and Enter MySQL Database credentials on the next page:

Step 5. Connect Twilio

You can obtain Twilio Account SID and Twilio Auth Token from the Twilio Dashboard. If you don’t have a Twilio Account, you can try Twilio for free by clicking here.

Your Account Sid and Auth Token are the “master keys” to your Twilio Account.

Connect Twilio

Now, we can go ahead and complete this step by integrating Twilio with OpenVBX using Twilio Account Sid and Twilio Auth Token.

Step 6. Connect Your Email Account.

Add an Email Address to your OpenVBX so that you can receive messages and notifications through Email. It’s possible that Email sending or receiving may not work on Google Cloud Instance because of security issues, so recommend reading an Article about it on our Knowledge Base by clicking here.

Step 7. Setup Your Account.

Setup an admin account on OpenVBX that you can use to perform administrative actions. Make sure that you carefully review the credentials otherwise it would be very hard to reverse the damage.

OpenVBX will take a minute to install on your server and display confirmation, similar to this:

4. Install SSL Certificate

Open Terminal so that we can configure SSL for our domain.

Step 1. Clone Certbot from Git

You can download the Certbot package on your Instance from Github by running the following command.

sudo clone git https://github.com/certbot/certbot.git

Step 2. Install Certbot SSL

Now we can install SSL by typing the following instructions below:

Go to Certbot directory

cd certbot

Run Certbot-Auto Package

./certbot-auto

Important Steps of Configuration:

  • Agree with terms and conditions
  • Enter your Email address to receive expiry notifications within 90 Days
  • Enter Domain Name for SSL Configuration.
  • Select 2 to redirect HTTP traffic to HTTPS
  • Restart Apache

Restart Apache

sudo service apache2 restart

Step 3. Configure Certbot to Auto-Renew LetsEncrypt SSL.

Now that we have Setup LetsEncrypt SSL, we need to configure Certbot Auto-Renew script to ensure that the domain always redirects to HTTPS.

Steps of Configuration:

We have deployed Certbot in the home directory, Lets, go back to Terminal and locate Certbot-Auto Package in Certbot folder.

ls 
cd certbot

If you have downloaded the certbot-auto package to a different directory, it is important to locate it. If you cannot locate the certbot-auto package, you can re-download the package by executing the following command:

sudo wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto

If wget returns an error, then run the following command to install wget and repeat the step mentioned above

sudo apt install wget

Now, we need to move a Certbot Auto-Package file to LetsEncrypt directory by executing following command :

sudo mv certbot-auto /etc/letsencrypt/

Next, we need to edit Crontab file. You can open your crontab file by executing the following command.

sudo crontab -e

At the bottom of your crontab file, you will enter a script which will tell your server to check for certificate renewals once per week and to automatically renew the certificates if they are about to expire.

Copy Paste the following Command

45 2 * * 6 cd /etc/letsencrypt/ && ./certbot-auto renew && /etc/init.d/apache2 restart

Restart Apache

sudo service apache2 restart

Step 4. Test HTTPS Redirect

Open your web browser and type the URL to test whether your domain redirects from HTTP to HTTPS automatically.

(Example Domain) 
http://openvbx.sinxloud.com

That’s it!

Now that you’ve Setup OpenVBX on Cloud and Configured SSL. Also, You don’t need to worry about renewing SSL again!

Go ahead and start using OpenVBX.

If you encounter errors or problems during or after the installation. Lets us know in the Comments below!

Need Help or have any questions. Get in touch for Support!

Originally published at sinxloud.com on August 6, 2018.

--

--