📜 ⬆️ ⬇️

Configuring Nginx + LAMP server at home Part 2: Configuring the backend: PHP + MySQL

Hello.

In the previous article , we learned about configuring the nginx + apache bundle in the hosting mode and the dotdeb repositories.
In this article we will learn about the configuration of backend: PHP, MySQL.

In the PHP part, we will introduce the following topics:
- general PHP setup
- the correct PHP + Postfix setting for sending emails via the internal SMTP server using the mail () function,
- setting up caching of code and / or data based on APC.
')
As part of MySQL, I will try to reveal the basic points of improving performance, because by default the MySQL server is configured very inefficiently.

Who are interested, welcome under the cat



Information:


I myself am not a database tuning pro. There are really cool peppers for that, and they cruelly torment the databases in different configurations on test stands and on real databases for maximum performance for specific tasks. This article is easier. I estimated the basic configuration by eye + corrected all the problems that I saw in SHOW VARIABLES . It feels like after normal tuning the main resource began to work faster than before.

Again, from the previous article, we give a diagram of the architecture of the system being configured, for a visual representation of server resources (click-through)



PHP 5.3.18 setup


In the beginning, as always. I ask my configs php + apc: yadi.sk/d/0OuPvlBS0t01O

- General PHP setup
In general, I did not find anything interesting in the php.ini file. However, there is something to pay attention:

It is very important if you take packages from dotdeb:

Performance and resources:

Hiding PHP presence

A few words about the error output (+ Hiding the presence of PHP 2):

- Setting up cache APC (version 3.1.9):
APC caches opcodes, in addition, it can cache data. I use APC for the reason that Yii recommends it. In Yii, there are already written classes for working with this cache. Other casher did not consider and did not compare for the above reasons.

The file config is empty by default, all values ​​are set by default. In particular, 32M is allocated for caching - enough for the code, not for the data.
In the file specified by me, you should definitely pay attention to the following:

- Setting up the mail () function:
Out of the box, the mail () function should not work. In order for it to work, a properly working SMTP mail server is needed. In the previous article we installed such a server.
It is worth setting to pay attention to the following things:


MySQL 5.5.28 Setup


While reading the documentation I stumbled upon the fad settings at the level of fiction. People deliberately start tests to squeeze out of the database maximum performance of up to 30 percent on certain settings and on a certain hardware.
We will not have this. We will simply follow common sense and documentation.

Welcome to configs: yadi.sk/d/T1ov6qAF0t82y

Configuration file structure:

In the my.cnf file, please pay attention to the following settings.

- SHOW VARIABLES
To view what operations the database performs, SHOW VARIABLES was created. With it, you can learn about such things as the number of input-output operations, the number of hits in the cache, the number of sorts through files and more. I advise you to review.
In the configurations, next to each setting, affecting the performance, there is a link (see) to which parameter SHOW VARIABLES should be viewed. For all other details, please refer to the documentation.

Some settings that should be noted:


All other parameters can be found in the configuration files.

PS: Wow damn poured. Hope not too sloppy? If at least 70% managed to convey, then it is good.

If this article is to taste, then I am going to write about the mail () + postfix + dkim setting in the spirit of a series of articles. Then write about setting permissions on the server. Then write about the different experience of owning a server at your disposal, in the same place we will try again to give the server scheme and paint the main nodes and memory consumption and I think I will also stuff a script for server deployment and server management (add and delete users at the level) and explain all the nuances accordingly associated for example with the naming standards adopted by me. At the end of the entire cycle of articles, I would like to introduce my home server, which, by the way, you can easily scale by adding new virtual machines and laptops + virtual machines to the “rack” =). All settings are first tested on this small server before they get to the working servers.

Thanks for attention.

UPD 2012.11.26 13:30 - Judging by the karma, at this stage we will finish writing articles. But in vain, because nowhere on the Internet you will find an overview of the full cycle of setting up a web server and sharing your experience, just a bunch of different author manuals. Thank you for your attention, I wish you all good luck.

Source: https://habr.com/ru/post/160189/


All Articles