Installing WebAgent on the AWS Bitnami server as a sub-domain

In a prior post, I went through the process of installing an Amazon EC2 instance using the Bitnami LAMP AMI (Amazon Machine Image). I assigned an Elastic IP address and updated my DNS to point to it. This gave me a web address like "www.earthasylum.com" and when I open that in a browser, I see this...

This is the default web page for the Bitnami server and it exists in the /home/bitnami/htdocs folder on the server. If you use the Bitnami server the way Bitnami intends, you can install applications into the /home/bitnami/apps folder and access those apps by appending the app name to the url. For example, I could install WordPress in /home/bitnami/apps/wordpress and access it via http://www.earthasylum.com/wordpress.

I’m not interested in installing Bitnami apps, I want to install WebAgent Navigator.

 

Exporting WebAgent databases using phpMyAdmin

Since I already have WebAgent running on another hosted server, this is easy enough to do.

Step 1 - Make a copy of /home/bitnami/htdocs (just because)
Step 2 - Upload all of the WebAgent code to /home/bitnami/htdocs
Step 3 - Export the WebAgent database from my current service provider through phpMyAdmin
Step 4 - Import the database on the Bitnami server, again, using phpMyAdmin

WebAgent has some other configuration setting needed to run that I won’t document here but it involves creating a few folders, creating a .htaccess file, setting keys, and loading a keychain table for database access. These things are not readily transferable from one server to another.

 

WebAgent Navigator Login

With that done, when I go to http://www.earthasylum.com, I’m running WebAgent Navigator!

WebAgent is installed as the default app using the MySQL database on the local server (local to WebAgent). All self-contained on the Amazon EC2 server instance.

I used this configuration for some time as I continued to develop WebAgent. I even added a QueueMetrics database even though I did not have QueueMetrics installed yet.

 

But this is not the configuration I wanted for the server. First, I wanted a sub-domain on “webagentnavigator.com”. Actually, a few sub-domains. Since webagentnavigator.com is used for this blog/web site, I can’t transfer the domain, but I can point sub-domains to the Bitnami server.

But the Bitnami server doesn’t really support sub-domains, at least not multiple sub-domains. Bitnami wants to use folders. Where I want “demo.webagentnavigator.com”, Bitnami wants “www.webagentnavigator.com/demo”.

I did enough digging and scratching on how Bitnami wants to setup custom apps (like “www.webagentnavigator.com/demo”) that I was able to figured out how to do custom sub-domains (like “demo.webagentnavigator.com”), and it’s really not that hard.

First, I went back and un-did the WebAgent install and put the Bitnami default web page back - just because.

Then…

Step 1 - Create the app folder(s)

In the /home/bitnami/apps folder, I created a “demo” folder.
Within that folder, I created a “htdocs” folder and a “conf” folder. WebAgent also requires a “etc” folder for private storage, so I created that as well.

Step 2 - Create the Apache configuration files

Within the “conf” folder, 2 files are required: “httpd-vhosts.conf” and “httpd-app.conf

 
Screen Shot 2019-10-26 at 2.26.46 PM.png
 

• httpd-vhosts.conf defines the virtual host (demo.webagentnavigator.com) we want. It contains this:

<VirtualHost *:80>
    ServerName demo.webagentnavigator.com
    ServerAdmin kburkholder@earthasylum.com
    DocumentRoot "/opt/bitnami/apps/demo/htdocs"
    Include "/opt/bitnami/apps/demo/conf/httpd-app.conf"
</VirtualHost>

Note the DocumentRoot - /opt/bitnami/apps/demo/htdocs is the real pathname. /home/bitnami is an alias (symlink).

• httpd-app.conf is the directory options file for the DocumentRoot defined in httpd-vhosts.conf and, as you see, is included at the end of httpd-vhosts.conf. This file contains:

<Directory "/opt/bitnami/apps/demo/htdocs">
    Options +MultiViews +FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>

    RewriteEngine On
    RewriteCond % !^/\.well-known
    RewriteRule ^index\.php$ - [S=1]
    RewriteCond % !-f
    RewriteCond % !-d
    RewriteRule . index.php [L]
</Directory>

Step 3 - Tell Apache to use those files

In /opt/bitnami/apache2/conf/bitnami there is a bitnami-apps-vhosts.conf file. It is automatically included in the Apache configuration. All we have to do is add a line telling it to include our new httpd-vhosts.conf file. So we add…

Include "/opt/bitnami/apps/demo/conf/httpd-vhosts.conf"

…to the end of the file. It should look something like this:

# Bitnami applications installed in a Virtual Host
Include "/opt/bitnami/apps/phpmyadmin/conf/httpd-vhosts.conf"
Include "/opt/bitnami/apps/demo/conf/httpd-vhosts.conf"

Step 4 - Upload the WebAgent source code

I uploaded the WebAgent source code to the /home/bitnami/apps/demo/htdocs (also known as /opt/bitnami/apps/demo/htdocs)

Step 5 - Restart Apache

I opened a terminal session with my WebAgent_ssh.command script and run:

sudo /opt/bitnami/ctlscript.sh restart

This restarts all of the Bitnami services, including Apache, and may take a minute or two.

Step 6 - Update DNS

I go to my DNS service provider and I add “demo” to the webagentnavigator.com DNS zone, pointing it to the public IP address of the Bitnami EC2 instance.

HOST        TTL     TYPE    IP  
demo        86400   IN  A   3.230.14.247

And, BAM!, I can now open “http://demo.webagentnavigator.com” in my browser.

I repeated these steps for the other sub-domains I want running on this server - including “phone.webagentnavigator.com”.

The softphone scripts that WebAgent uses are all HTML/JavaScript files. They are considered “static” meaning that there is no server-side code (i.e. PHP). The scripts are intended (though not required) to run from their own sub-domain making it easy to share with multiple instances of WebAgent. So “/home/bitnami/apps/phone/htdocs” is where I installed the softphone code and it gets loaded in the browser via an iframe from “phone.webagentnavigator.com”

 

WebAgent should be using SSL (https) when not running from a private network, so next up, I’ll write about generating keys and enabling SSL with Let’s Encrypt and the Bitnami HTTPS Configuration Tool.