How to install Cloudgizer


Requirements


To install Cloudgizer you'll need at least a minimal installation of RedHat/CentOS version 7 Linux operating system and an internet connection.

Other software is installed and configured, such as MariaDB database, Apache web server and Postfix mail transfer agent. Read an overview.

Create a Linux user

Create cld user to host Cloudgizer applications. Login as root before proceeding:


su -


Create a cld user and set password:


useradd cld
passwd cld


When prompted, enter your password twice.

Add sudo capability to this user:


usermod -aG wheel cld


In order to get the source code for Cloudgizer, install git:


yum -y install git

Install Cloudgizer


Login as cld user:


su - cld


Get source code into a new directory:


mkdir -p src
cd src
git clone https://dasoftver@bitbucket.org/dasoftver/cloudgizer.git .


If you need a particular version, for example version 1.2, specify it instead of the above (to see a list of available versions, use git tag):


git clone --branch 1.2 https://dasoftver@bitbucket.org/dasoftver/cloudgizer.git .


Next setup the environment and dependencies.

The MariaDB database setup utility will first setup root database password. In here root_pwd is used - use your own password instead. Press Enter to other questions. Note that MariaDB setup may change so the answers may vary.

For Postfix setup, enter web domain of your server (for example myserver.com or localdomain) and web address (for example dev.myserver.com or localhost.localdomain).


sudo ./setup_env
sudo ./setup_maria
sudo ./setup_postfix


Install the Cloudgizer installer:


./setup_cld


Cloudgizer is now installed.

To test the installation, type:


cld


You should see Cloudgizer help page.

In order to get started with your own application, you must install the Example application.

Create the Example application


Login as cld user and get the source code for the Example application:


cd $HOME
mkdir -p example_src
cd example_src
git clone https://dasoftver@bitbucket.org/dasoftver/cloudgizer_example.git .


If you need a particular version, for example version 1.2, specify it instead of the above (to see a list of available versions, use git tag):


git clone --branch 1.2 https://dasoftver@bitbucket.org/dasoftver/cloudgizer_example.git .


Create database objects. We will assume root mariaDB password is root_pwd - substitute for your root password:


mysql -u root -proot_pwd


Execute this in mariaDB shell - we will assume newly created user will have password pwd - substitute for your desired password:


create database example;
use example;
create user example;
set password for example=password('pwd');
grant select,insert,update,delete on example.* to example;
source create.sql


Edit .db file (for example vi .db) to have only the four lines in it:


localhost
example
pwd
example


Set proper permissions on this file:


chmod 600 .db


Create the Example application installation file:


cldpackapp
cp example.tar.gz ~


This will create file example.tar.gz in the home directory which you can use to install the example application on any machine that has Cloudgizer installed - see the following.

Install the Example application


First unpack the example.tar.gz file (see above on how to create it):


cd ~
sudo rm -rf deploy
tar xvfzm example.tar.gz
cd deploy


Edit file appinfo. Assuming your email address is youremail@somewhere.com, your server name is yourserver.com, root database password is root_pwd, and the password for new database to be created is example_pwd, set these variables:


...
export CLD_SERVER="http://yourserver.com"
...
export CLD_EMAIL="youremail@somewhere.com"
...
export CLD_DB_ROOT_PWD="root_pwd"
...
export CLD_DB_APP_PWD="example_pwd"
...


Install the Example application:


cldgoapp create


At the end of installation try the URLs shown to validate the installation.

If you want to re-install, you must edit appinfo and supply the passwords again.

The Example application serves as an example and a smoke test for Cloudgizer.

To create your own application, you'll clone the Example application.

Clone the Example application into your own


You will create a new application named myapp. Go to the Example application's source code:


cd ~/example/src


Edit appinfo file to change the application name:


...
export CLD_APP_NAME="myapp"
...


Create a new installation file and copy it to home directory:


cldpackapp
cp myapp.tar.gz ~


You have created the installation file and now you'll install it in order to clone the Example application.

Once installed, it will be a separate application as it will have its own directory, database and Apache handler.

Install your application


To install the application from the installation file created, first unpack it:


cd ~
sudo rm -rf deploy
tar xvfzm myapp.tar.gz
cd deploy


Edit appinfo file to set the root database password (root_pwd) and assuming the password for the new database myapp is myapp_pwd:


export CLD_DB_ROOT_PWD="root_pwd"
...

export CLD_DB_APP_PWD="myapp_pwd"


If you're installing on a different server, change CLD_SERVER appropriately and if application email address is different, change CLD_EMAIL too.

Install your application:


cldgoapp create


You have created a new application under ~/myapp directory. Now you can run it and develop it any way you want.

Develop your application

Your code


You'll add your own code here as an example of writing with Cloudgizer. Go to the source code:


cd ~/myapp/src


Add your own code by creating new file mycode.v with the following content:


#include "cld.h"
#include "common.h"

void mycode()
{
   /*<
       output-http-header

       Output from my new code!
   >*/
}


Add the declaration for the above function mycode(). Edit common.h file:


...
void mycode();
void home(); ...


GET/POST handler

Add your code to the request handler. In this case when URL has page=myrequest, your code will run.

Edit cld_handle_request.v file:


   ...
   input-param page

   if-string page="myrequest"
       c mycode ();
   else-
if-string page="home"
       c home ();
   else-if-string ...


Make

Add your new file to sourcelist. Edit sourcelist file and change/add the following lines as indicated:

...
SOURCE_FILES=mycode.o test_cld.o home.o ...
...
mycode.o : mycode.v $(CLDINCLUDE)/cld.h $(HEADER_FILES)
test_cld.o : test_cld.v $(CLDINCLUDE)/cld.h $(HEADER_FILES)
...


To make your code:


cldbuild
sudo service httpd restart


Test

To test it in the browser, enter this URL and replace myserver.com with your server name:


http://myserver.com/go.myapp?page=myrequest


Tips

If you change database tables or want to recompile all Cloudgizer source files:


cldbuild clean
cldbuild
sudo service httpd restart


You can remove the example code such as home.v and test_cld.v (generally it's the code that's called from the initial cld_handle_request.v) by editing the same files above.

Take a look also at create.sql (where create statements for database objects must be listed) and create.sh (where you'd setup anything that Cloudgizer doesn't already do, such as create the database objects your application needs).

Distribute your application


To create installation file for distribution use cldpackapp. This installation file can be deployed anywhere, such as a QA box or to production.

If you want to distribute the source code, edit appinfo file to add the new source file (in this case mycode.v), otherwise skip this step:


...
export CLD_APP_FILES="mycode.v home.v ..."
...


Create the installer:


cldpackapp


This will create file myapp.tar.gz you can deploy anywhere, the same way as explained in Install your application.

Software dependencies

MariaDB

MariaDB database and MariaDB LGPL client library will be installed. my.cnf file is configured for better performance.

Postfix


Postfix is installed to replace existing sendmail. It is configured to send email, including generating a TLS (Transport Layer Security) key for encryption.

Note however that email delivery depends on factors outside of your server.

For example, your server should have a reverse DNS (Domain Name System) record and an SPF (Sender Policy Framework) record. You can typically set these through your name registrar and server/VPS (Virtual Private Server) providers' online tools.

Email providers don't accept mail from local computers, such as a home computer. You can still send emails to local Linux users for development and testing purposes.

SELinux


SELinux mode is set to permissive; if you need it you can set policies yourself. Many VPS boxes, dedicated servers or cloud instances have it set to permissive by default.

Apache


Apache web server will be setup with firewalld configured.

The default Apache user is set to the Cloudgizer user, in this case cld user.

So User and Group in /etc/httpd/conf/httpd.conf file will be:


User cld
Group cld


All Cloudgizer applications have Apache module handler names starting with cld_handler_:


AddHandler cld_handler_myapp .myapp


When application is removed, remove it's AddHandler.

Any existing web content should be under the home directory of Apache user, which is now cld, so for example your DocumentRoot might be:


DocumentRoot "/home/cld/web"

Other software


The setup will also install other necessary software, such as gcc C compiler, OpenSSL libraries etc.

Large example


Take a look at Rentomy. In the Download and Installation section you'll see the same deployment process as described here.

All Cloudgizer applications follow the same process.

Rentomy also has additional installation variables, backup system, application updates, background jobs etc. It's a large business application - look at the source code and especially appinfo, create.sql, create.sh files to learn more.

Learn more

Check out Cloudgizer documentation to learn more.