Cloud with Redhat OpenShift Flex

This page is a tutorial to explain how to install Dolibarr ERP-CRM on the Redhat OpenShift Flex Platform www.openshift.com

click twice on image to enlarge

Image 1
Url openshift.JPG


A little about OpenShift

OpenShift Platform as a Service

OpenShift is Red Hat's Platform-as-a-Service (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment. With OpenShift you have choice of offerings, including online, on premise, and open source project options.

OpenShift provides help to build and deploy web applications, mobile backends, service-oriented architectures, and get your favorite services.

Openshfit works with Gears and Cartridges, which are terms with which we have to familiarize ourselves.


What's a Gear?
A gear is a resource-constrained container that runs one or more user-specified software stacks, also known as cartridges. Each gear has a limited amount of RAM and disk space.

If an application needs more resources, it can be configured to automatically use more gears.


How Do Gears Work?
Let's look at an example Drupal-based app running on OpenShift. We can estimate the needs of the app at different stages.

  • 15 pages/second
  • Hundreds of articles
  • ~ 50k visitors per month
  • 3 Small Gears
  • Free plan

As we see, a free plan, it may be sufficient for a small or medium company.

For larger companies, you can switch to the next plan.


In OpenShift, we have two possibilities, to launch Dolibarr.

1 -. To extend or create your own modules.
2 -. To put in production our Dolibarr.


Advantages offered OpenShift

It is a secure site, which is accessed through SSH.

It is scalable
Application scaling enables your application to react to changes in traffic and automatically allocate the necessary resources to handle your current demand. The OpenShift infrastructure monitors incoming web traffic and automatically brings copies of your web cartridge online to handle requests.

Gives us total control on our database for us to connect remotely to via a GUI client.

If we opt for MySql, we feature the InnoDB engine, essential for transactions.

It gives us the possibility to share SSL Certificates of RedHat or customize our own SSL, if you have one. Essential to send our data of login or bank transfers, encrypted and secure.


Create an account

Click in SIGN UP

Image 2
 

Fill your data to create an account. Click in Sign Up


Image 3
 

They will send an email to your email account to confirm. Click in Verify your Account.

Create an instance/domain

Part 1 - Create instance

Click LOG IN back and show us the initial aspect of our console applications.

Image 4
 

Click in Create your first application now


Choose a web programming cartridge

Image 5
 

1. Choose a type of application


Image 6
 

2. Configure the application.

It is important to define the domain name, for this tutorial we used sdme. The domain, you cannot change it unless, we delete all our applications and start again from scratch and that is something that nobody wants.

Also, we will have to report, if we have an external git repository with our code.


Here comes the fun part.

In scaling change to Scale with webtraffic.

The creation of this application, used a Gear of the 3 that we have, indicates precisely next to the Create Application button.

Click in Create Application.

Image 7
 

When the application is scalable, you cannot add more Cartridges, the Gear. For example we do want to use MySQL, you must go apart, another Gear.

In the image above, we see that our Gear, has added the load balancer, which will make our scalable application.

Up on the right end, there is also a button, in case we need to restart the Gear.

Note. - With PuTTY, we could resolve more explicit requirements to control our Gears with command line.


Click on the link Web load Balancer.

Image 8
 

HAProxy in Action.

Image 9
 

If we see our url startdolibarr-sdme.rhcloud.com this is the initial appearance, it has.


Part 2 - Setup admin tools

So far so good. Now to the second part of our tutorial.

For this part, will be referred to the administration of our application, there are two ways, the first is by CLI (command line based Ruby) and the second, more declarative form, console and SSH.

I chose the easiest way I've intuitive, which is the second option for this tutorial.


Hands to work.

We need a SSH / FTP client like WinSCP and PuTTY.

We download and install.

Image 10
 

Inside the folder where you installed WinSCP, find the folder PuTTY and inside this folder, the puttygen.exe program, this program is important because it is the one that will help us generate our SSH access, to connect to our Gear.


Double Click in puttygen.

image 11
 

We leave the default values, SSH-2 RSA, and the number of bits in 2048.

With these values and will have a key, heavily encrypted.

Click in Generate

Image 12
 

To generate our key, we must move the mouse pointer constantly in the blank space of program.


Image 13
 

Once our key generation is complete, we will add a passphrase.

Click Save public key to save our public key, we give the name of rsa.pub, do the same with save private key, and give the name of rsa.ppk.

A public key is like a lock on a door and the private key is like a key that opens the lock.

We mark the generated code in the text area and copy it, then we go to our OpenShift console.


Image 14
 

Paste the code into Paste the contents of your public key file (. Pub) and click Save.


Image 15
 

Perfect OpenShift now has our lock and we have the key.

Now we go to the Applications tab in our console OpenShift.


Click on our application startdolibarr.

Click in Want to log in to your application?.

Image 16
 

Copy the code ssh 53641a41e0b8cdf5ec000b76@startdolibarr-sdme.rhcloud.com


We opened our WinSCP.

Image 17
 

We put the first part, 53641a41e0b8cdf5ec000b76 before the @ in the User name field, and the second part, startdolibarr-sdme.rhcloud.com after the @ in the Host name field.

It is advisable not to place the password / passphrasse, at this point, for security reasons. We'll use it later.

Click in Advanced.


Image 18
 

In Private key file: select your private key rsa.ppk, click OK, click save, and click Login.


Image 19
 

When we leave this nice window click Yes.


Image 20
 

Here we place our passphrase and click OK.


Image 21
 

Viola we have access via SSH to our Gear.

On the left is our local space and right remote.


Submit Dolibarr files

Image 22
 

We went down the generic version of Doibarr.


Image 23
 

In the remote part, selected route /var/lib/openshift/53641a41e0b8cdf5ec000b76/app-root/runtime/repo

Transfer the Dolibarr folder on the local machine to OpenShift, pressing F5. This process may take several minutes, so while we wait, we will work to create our Gear for the database.


Image 24
 

We return to the console and with our OpenShift application selected, we click on the bottom of the Databases section and select Add MySQL 5.5


Image 25
 

Click in add Cartridge.

Note -. In a normal application without Scale, the Cartridge Mysql be added to current Gear, but in our case, OpenShift reports that will address a new Gear for MySQL.


Image 26
 

Copy the MySQL access credentials. They will be used later to access our data base.


Image 27
 

Once you have completed the upload of dolibarr described in picture 23. Edit the index.php file.

We opened our favorite text editor and replace with the following code.

<?php
header("Location: dolibarr/htdocs");
?>

We make a copy of index.php in dolibarr folder and re-edit it and remove dolibarr/.

<?php
header("Location: htdocs");
?>


Image 28
 

What we have just done, serves don't shown the structure our folders and files of dolibarr from the web browser, with the index.php we force redirect to the home of Dolibarr.

Finally, before starting the configuration of dolibarr, should use SSL (encryption protocol), which provides security when sending our data from the web browser to the server. The use of SSL provides plus extra measures of the dolibarr security, which are already good.

We opened our text editor again and add the following.

Save with the name .htaccess right next to our dolibarr folder and index.php.

As shown in the following image.


Image 29
 

 


Image 30
 

Image 31
 

We see the SSL certificate is accepted by the browser.


Run Dolibarr install Wizard

We start the Dolibarr setup.

We select from the drop down, Default language to use (language code):, the appropriate language and click Next step.


Image 32
 

Click in start.


Image 33
 

We review the image 26, when we created the MySQL Cartridge.

And we focus on the lines.

  • Root User: adminCRERXju
  • Root Password: tccRTZ8-xCnK
  • Database Name: startdolibarr
  • Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/


To create the connection to the database, OpenShift gives us some environment variables. For dolibarr can connect to the database, we need to know the value of these variables, so back to WinSCP and the .env/mysql folder find these variables, as shown in the picture above.

Click the right mouse button on OPENSHIFT_MYSQL_DB_HOST, click on edit and show us the value of the variable, copy and paste into the Server field as shown in the image below. We do the same for OPENSHIFT_MYSQL_DB_PORT variable and paste its value in the Port field.


Image 34
 

Note.- When you will these follow steps for the host and port for your particular installation, should be different than shown in this example.

Note2. - In this step, we also could create a different data base and a different owner, because be have the superuser credentials of MySQL, but this step does not touch it here today.

Click Next Step and displays the following window.


Image 35
 

This screen basically tells us that the connection to the database has been established and this information is saved in the configuration file conf.php of dolibarr.

Click Next Step and start creating tables in the database, necessary for the work of Dolibarr.


Image 36
 

This screen reports that have completed the creation of the tables.

Click in Next step.


Image 37
 

We fill the fields with the username and password, which will be the administrator, for this example I used admin/admin. For the real case should be a stronger password.

Click in Next step.


Image 38
 

Click in Go to Dolibarr (setup area).


Image 39
 

Insert the username and password of the administrator, as defined above and Viola. We are within Dolibarr.


Appendix: Connection remote MySQL

As a final step, we will see the connection from a local client database, to our remote MySQL.

For this example I will use HeidiSQL, which serves both MySQL or PostgreSQL database and is Free.

Open HeidiSQL.

The first thing to do is select MySQL (SSH tunnel) Network type drop down, in so doing, HeidiSQL adds a new tab called SSH tunnel, as shown in the image below.


Image 41
 

Note that, in the plink.exe location: field must specify the path PuTTY.exe, in the Password field entered the passphrase and Local Port field should always be in 3307.

We return to the Settings tab.


Image 42
 

We obtain the hostname and port of MySQL to connect to Dolibarr database. Top image 33. Fill the fields with the credentials of the database, select the database, click in Save and click in Open to test the connection.

Image 43
 


Addendum

Connection to MySQL Gear

You remember when we obtained the hostname and port of MySQL to connect to Dolibarr database. Top image 33.


Image 44
 

The first part of the Hostname: is also the Username: 5364c670e0b8cd09f500036d-sdme.rhcloud.com click in Advanced and verify that everything be as the image 18.

Click in Save and click in Login.

With open WinSCP, go to the Options menu --> preferences --> Integration --> Applications as shown in the image below.

In the PuTTY/terminal client path: field select the path where we have the putty.exe and mark the three checkboxes.


Image 45
 


Each time you start in with WinSCP session also will start session in PuTTY. As seen in the image below.


Image 46
 

Having PuTTY open and connected to the same session, allow us to execute command line statements to stop or start the MySQL server or Gear.

Note -. Also in the remote part of WinSCP, we can navigate to folders as /var/lib/openshift/5364c670e0b8cd09f500036d/mysql/data/startdolibarr where this physically our database or we can go to /var/lib/openshift/5364c670e0b8cd09f500036d/app-root/logs to see MySQL logs.

If we write help in the PuTTY window, will show some important commands.

Among the common commands are:

ctl_app
Control your application (MySQL)

  • ctl_app start
  • ctl_app stop
  • ctl_app restart
  • ctl_app status


ctl_all
Similar to ctl_app but we can control the whole Gear.

  • ctl_all start
  • ctl_all stop
  • ctl_all restart
  • ctl_all status

Cited here www.openshift.com/developers/remote-access where we find most useful commands.

And with that we end this tutorial.