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.
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
...
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 >>>
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.
In this part, we will see how to use phpMyAdmin connected to a MySQL database provided by SlapOS.
When you connect to the webrunner for the first time, it will ask you some informations.Then click on clone a repository.
Select "http://git.erp5.org/repos/slapos.git" as git repository. Put a dummy name and email if necessary.
Then, go back to webrunner home page, click on "open your software release".
Select software/lamp-template and click on the "Open software" button. It will redirect you to the software profile edition page.
Click on the top middle button "Go to Current Software". It will allow you to edit files in your Software Release directory.
Select the "template/php-myadmin.inc.php.in" file and be prepared to edit it.
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"
It is important that you fill out the required fields. When it is finished, do not forget to click on "Save".
Here is an example a of correctly filled software profile.
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.
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.
Click on SLAP RESPONSE. This screen shows how to connect to the started instance, with the backend_url
Click on the second slappart in bold, and get your login and password from the url parameter (it should be mysqls://login:your_password@…)
This is real screenshot done after profile was instantiated.
As one can see, it was possible to connect to PHP Application configured with MariaDB.
As everything worked it is time to stop the instance and say goodbye, so please click on "Destroy Instance"