Most Powerful Open Source ERP

How to Host phpMyAdmin with SlapOS

  • Last Update:2014-12-30
  • Version:005
  • Language:en

How to install phpMyAdmin

You can view this tutorial in presentation mode.

After having some introduction to SlapOS theory it is time to deploy first application.

On the web there is popular term - LAMP. It resolves to Linux/Apache/MySQL/PHP.

phpMyAdmin is the simplest possible application in LAMP stack. This is PHP based administration tool for MySQL.

We will create everything that is needed to port and install a PHP application in SlapOS, using phpMyAdmin as an example.

We will be needing an instance of Web Runner that we can use to develop our profiles.

Agenda

  • How to use templates in python
  • How to add your PHP software to SlapOS

How to use templates

Templates flexibility

SlapOS uses templates engines to generate documentation.

Any template mechanism available in python can be used.

Here are some examples :

Python built-in:
  string.Template
  % operator with dictionary

Extensions:
  ConfigParser
  Genshi
  ...

Texts in python

Here are some string manipulations using the "%" built-in operator :

>>> text = 'Sun is bright'
>>> print text
Sun is bright
>>> text = 'You have 20% more'
>>> print text
You have 20% more
>>> text = 'Some other text %s'
>>> print text
Some other text %s
>>> print text % 'with words'
Some other text with words
>>>

Python strings and template

For OSOE training, default python template mechanism is used. It is easy to use, does not require any dependencies and it is feature enough for tutorials. It has the advantages of being built-in, simple and easy-to-test with python interpreter.

Let's see how it works :

>>> text = "Hello %(name)s"
>>> d = {'name': 'John Wayne'}
>>> text % d
'Hello John Wayne'
>>>

In more advanced recipes, different template mechanisms can be used.

How to add a PHP software

In this part, we will see how to use phpMyAdmin connected to a MySQL database provided by SlapOS.

Configure webrunner (1)

When you connect to the webrunner for the first time, it will ask you some informations.Then click on clone a repository.

Configure webrunner (2)

  • Configure git repository: Home->Create
  • URL is: http://git.erp5.org/repos/slapos.git
  • Name/email are not important

Select "http://git.erp5.org/repos/slapos.git" as git repository. Put a dummy name and email if necessary.

Configure webrunner (3)

Then, go back to webrunner home page, click on "open your software release".

Configure webrunner (4)

Select software/lamp-template and click on the "Open software" button. It will redirect you to the software profile edition page.

Click on Current Software

Click on the top middle button "Go to Current Software". It will allow you to edit files in your Software Release directory.

Open template

Select the "template/php-myadmin.inc.php.in" file and be prepared to edit it.

Edit configuration template

This template shall be edited as shown in the screenshot to add the SlapOS parameters.

When it is finished, do not forget to click on "Save"

Edit Software Profile

In slaprunner, go to "Software : edit".

It is important that you fill out the required fields. When it is finished, do not forget to click on "Save".

Filled profile example

Here is an example a of correctly filled software profile.

Install software

As SlapOS Web Runner is configured now it is time to install the software. Click on Run Software, and be patient, the compilation can take several minutes. There might be problems in many places. Students shall fix them one by one until there is no errors in build log.

Run the instance

As soon as the software profile gets installed it is time to run instanciation. Click on Run instance, you will have to do it multiple times for MariaDB and all the required softwares to instanciate first.

Inspect

Click on SLAP RESPONSE. This screen shows how to connect to the started instance, with the backend_url

Inspect(2)

Click on the second slappart in bold, and get your login and password from the url parameter (it should be mysqls://login:your_password@…)

phpMyAdmin login screen

This is real screenshot done after profile was instantiated.

It Works!

As one can see, it was possible to connect to PHP Application configured with MariaDB.

Stop the instance

As everything worked it is time to stop the instance and say goodbye, so please click on "Destroy Instance"