
In previous articles, we told you
about the launch of the Jelastic.Cloud cloud platform on the Infobox, as well
as how we created the CMS directory to deploy them in one click on the Jelastic.Cloud platform and what high performance results we achieved by optimizing the web environment.
But, of course, in our catalog there are not all existing CMS, so now we will tell you how to independently deploy your PHP project to Jelastic.Cloud and optimize the environment for it. We will do this on the example of UMI.CMS.
Start by creating an environment. For most projects, the Apache + MySQL bundle will suffice.

')
How to upload project files to the created environment has been written several times already, so we will limit ourselves to
referring to the instructions . But with databases, the question is not so obvious. When creating a MySQL node, the root user password comes to the mail. The most common mistake is to use this password to connect the site to the database server. For this, it is better to create a separate user in phpMyAdmin:

Another common mistake is to specify a local host in the Host field. The fact is that in Jelastic the application server and the database server are separated, which means that user access will be only through the interface PhpMyAdmin and nowhere else. You can specify “Any host” in this field, or you can check with the technical support the internal address of your application server and allow access from it.
For ease of setup, you can also check "Create a database with a username in the name and grant full privileges to it" or "Grant full privileges to databases matching the pattern (username \ _%)", otherwise you also need to set permissions created by the user.
The next difficulty that can be encountered when deploying a project on Jelastic is connecting the site to the database. To connect, you must first look at the address of the database server:


And to use when connecting this address and data of the previously created user:


When the project is placed, you can think about optimizing the environment. Let's start with MySQL.
In the Jelastic control panel, select the “Configuration” item of the MySQL node and open the my.cnf file for editing:

We have 96 tables on our site. In order not to waste time opening them, let us keep them all open in the cache by changing the value of the
table_open_cache parameter to 100. By setting this parameter to be significantly larger than the number of tables, you increase the amount of RAM reserved for the cache, which leads to increased consumption , which means high costs without any gain in performance.
Now let's resolve requests by adding the variable
query_cache_size with a value of 16M. This is an average value, which will be enough for most sites (with the exception of online stores), but a different figure may be optimal for a particular project.
In addition to requests, it is desirable to cache threads. You can do this by adding the
thread_cache_size = 16 string (you can use 8 if you do not expect a high attendance of the resource).
Since the project in question is using InnoDB, you need to set the frequency of dumping the logs to disk using the
innodb_flush_log_at_trx_commit parameter. At the project debugging stage, you can use the value 1, but after completion of the main work it is better to convert the parameter to 2: this will ensure the maximum speed of the database server.
There are 2 more important parameters associated with InnoDB:
innodb_flush_method = O_DIRECT allows
you to avoid the situation when caching will be performed by the operating system and the MySQL server;
innodb_buffer_pool_size is set to 512 MB by default, which is unnecessary for small databases. With static database contents, this parameter should be set slightly larger than the database size. If information is constantly added to the database, then the parameter can be 1.5–2 times the size of the database and be periodically reviewed.
Having made all these changes, save the file my.cnf and restart the MySQL server.
Now let's move on to optimizing the application server, for this we will open the php.ini on the Apache node in a similar way.
One of the factors why a site does not work well on shared hosting often becomes a PHP accelerator, or rather its absence. Jelastic already has 4 accelerators preinstalled, all you have to do is enable the needed one by uncommenting the needed line in php.ini. Practice shows that the inclusion of apc gives the best result, so further we will discuss its use. At the same time, nothing prevents you from using another accelerator or even installing your own one by downloading the SO file to the modules folder and also connecting it to php.ini.
For optimal performance of APC, add the following lines to php.ini:
realpath_cache_size = 4M - the amount of memory allocated for caching the real path;
apc.ttl = 1800 - sets the cache time to 30 minutes (the optimal value may be different depending on the frequency of updating the content on the site);
apc.max_file_size = 4M - files larger than the specified value will not be cached in order to avoid an increase in RAM consumption;
apc.shm_size = 128M - maximum cache block size (the number of blocks can be increased using
apc.shm_segments );
Let's save php.ini and move on to setting up the web server itself. The settings file is in the conf directory and is called httpd.conf.
Most of this file does not affect the performance, we will be interested in only the section:
<IfModule prefork.c>
StartServers 1
MinSpareServers 1
MaxSpareServers 2
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 100
It should be replaced by:
<IfModule prefork.c>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 10000In order not to overload the article, we will not describe the value of each of the variables, just note that this configuration increases the speed of work, but at the same time leads to an increased consumption of RAM.
After making the changes, you must save httpd.conf and restart Apache:

The result of not too long work was the “excellent result” of the UMI.CMS performance index.

We hope that this article will help your projects to work faster! Well, web applications from our CMS directory for installations in 1 click on Jelastic and so everyone flies.
You can see for yourself by
taking part in the beta testing of the platform before October 15.