System Administration

How to optimize your web server (basic)

Jesús Maldonado

May 10th, 2017

Many times when we see that a service works, we assume that is ready to work in production environment, but not all the time is like this, we should always review and work so that the services are adapted in balance between the client’s needs and the Hardware capabilities.

In this study case we will talk about an environment with Apache, MySQL / MariaDB and PHP on Linux (Ubuntu) as an operating system (known as LAMP).


As we previously announced, we will work with a MySQL or MariaDB database.

First you must install a tool that will help detect the weaknesses of the current configuration, it is called “mysqltuner”.

To do this, the following line is executed:

sudo apt-get install mysqltuner

Once installed it is necessary to have the password of the root user, since it needs access to system tables. To run the tool:


You will then be prompted for the database administrator user (root) and your password. It will then perform an analysis of the current configuration of the database and give a report with to adjust the parameters with the recommended values. It is important that the analysis with mysqltuner is done 24 hours after its installation or restart of the database service, in this way will give the appropriate recommendations.

The values ​​that must be changed according to the recommendations of the report, can be done with the following command:


sudo nano /etc/mysql/my.cnf

For MariaDB 10

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Web server (Apache 2.4)

There are web tools that show the performance of the web server, one of them is

This page evaluates cache handling, images, external calls, and other important aspects that affect performance.

Within the report will give the recommended adjustments for the optimal functioning of the web page and the Apache service.


If the web page is a CMS or own development, you may need some general settings for its operation, for example if you have long processes, or uploading files of considerable size, then it is advisable to adjust certain parameters.

To edit the PHP configuration file in this case:

sudo nano /etc/php/7.0/cli/php.ini

And adjust these values:

post_max_size = 32M
max_execution_time = 120
max_input_time = 180
upload_max_filesize = 32M
max_input_vars = 6000


These are only the first steps for optimizing a web server, there are many other variables to take into account, soon we will be publishing more information in future posts.


Comments (0)

Leave us a comment

Citriom - All Rights Reserved