In Ubuntu, Debian and thanks to Almighty repository to install many programs, including serious server packages reduce the need to print one line of type sudo aptget install … more and wait a couple minutes and you have a program on your computer.
In principle, with the server, nginx, the situation is exactly the same, and the same maintainer in jealously watch that version of the program was always fresh.
But this approach, many believe not professional, they are fools, and others just love to compile from source, because to do it this fall on servers.
Because initially when I encountered it I have installed nginx from source, I‘ll describe this process.
At first, this article was meant to be a guide on how to install the server, but judging from the new-fangled trend, many large sites Runet, and foreign, are running ngnix, and such a small server, so comfort is fulfilling its responsibilities. On this I decided to study in more detail this server and its capabilities.
Due to the lack of doumentacii in the English language, I’ll translate and publish this article on the English language. As in other matters, and many others.
Instructions for installing from source code
Download the server from the site‘s creator, latest version:
Unpack the archive:
Now, if you have everything you need for default start compilation, if not then put needed:
Everything will be OK, but in the end we will see this error:
Plus carefully look into the field marked with * are likely much more is missing.
Fix this by running:
This is all necessary libraries.
Following these simple steps, the server is installed in the system.
If you are not satisfied with the standard way, then when you build, you can specify a convenient for you by including the corresponding keys.
— sets the directory where the files will be available for the server. This directory will be used for all relative paths specified./configure (except source code libraries paths) and the configuration file nginx.CONF. The default is the directory/usr/local/nginx.
— sets the name of the executable file of nginx. This name is used only during the installation. By default, the file is called prefix/sbin/nginx.
— sets the name of the configuration file nginx.CONF. If you prefer, you can always start nginx with another configuration file by specifying the command-line parameter-c < file >. By default, the file is called prefix/conf/nginx.conf.
— sets the filename, which is the main process. After installation, the file name can always be changed in the configuration file nginx.conf directive pid. The default file name is prefix/logs/
— sets the name of the primary file errors, warnings, and diagnostic. After installation, the file name can always be changed in the configuration file nginx.conf with error_log Directive. The default file name is prefix/logs/error.log.
— sets the name of the primary file server http requests registration. After installation, the file name can always be changed in the configuration file nginx.conf access_log directive. The default file name is prefix/logs/access.log.
How to manage your server?
Start the server with the command:
Will check its availability in processes:
It’s cool. Now you need to open the browser and enter the familiar http://localhost/
If you see the welcome message, then all is well.
Shut down the server by sending the master process signal QUIT:
Update server on the fly.
To upgrade the server to write the place of the old, the new executable file. Then you need to send a signal USR2 master process it will rename the file with a process to a file with the suffix. .oldbin suffix, such as/usr/local/nginx/logs/, and then run the new executable file, in turn, is their workflows:
To apply the new configuration, if you for example have updated configuration file, you must send the HUP signal to the server:
QUITgraceful shutdown
TERM, INT is the rapid completion of
HUP is a configuration change, update the changed time zone, starting new workflows with the new configuration, the smooth completion of the old workflow
USR1 is reopening log files
USR2 update executable file
WINCHgraceful shutdown worker processes
Where to find it?
This has already been pointed out above, but nevertheless, and this information does not hurt. As in its own Assembly, I did not change any of the standard ways, then the location is. Note that when installing the repository, the path will be different.
/usr/local/nginx/html is the folder where the Web page with a greeting that you saw in testing, ngnix, there can be put and your site. This is not quite correct, if this is your server.
/usr/local/nginx/conf/nginx.confhere is the main configuration file nginx.conf, it is followed by recording all directives.
If you have decided to make a server on nginx, and watching the network. And there spinning your personal website or something. You have to think about how to properly organize the structure of your site or sites and customize the groups and their permissions, quotas.
Start by creating a group www:
Create a user www:
Add user www www group:
Check the/etc/passwd/file for the same PID:
Change the PID to anyone you like, just don’t forget to change the PID in/etc/group
Group www.
Create a password for the user:
Now we’ll create the structure of the future site.
Most likely this is so:
Get a ready platform for the future of the site.
As you can see, all the folders belong to the user www.
And for all the folders have rehomed, 644 permissions (rw + r + r) and public 744 (rwx + r + r):
and now let’s edit the file/usr/local/nginx/conf/nginx.conf
which can provide everything you need for your server.
Here’s what I said:

Не советую выдирать из файла примеры, в конечном счете они могут вам пригодиться. Или сделайте backup файла, на всякий случай.

Сам файлик может валяться где угодно. Но если директория отличная от дефолтной, при запуске nginx это необходимо учесть с помощью ключа -c

Давайте посмотрим на работу сервера.
Запустите его и посмотрите на него в списке процессов. Это должно выглядеть так:

Everything is fine! The master process running from Ruth, the other two process, as we indicated in the file that belong to the user the World Wide Web and are not privegilirovannymi.
Now that we have some idea about how to install the server, its configuration and find all executable files, as well as how to start and stop, it would be nice to ask type: Er KHTML is certainly cool, but what about the more serious type of thread Che bundles with PHP and popular CMS??”
Install WordPress on Nginx
Let’s look at the server and how it works. In such a case, we will understand how to properly organize your server.
nginx works on non-blocking Sockets or the so-called state machine, what this means is that the server for each iteration of the loop socket of the chosen who is willing to work with the data (send/receive) by calling select(). After a socket is selected, the server sends the data or reads them, but does not wait for confirmation, and goes into the initial state of the event wait on another socket or handles the following, in which the event occurred during the processing of the previous one. Such obrazomnginx spends substantially less OS resources, such as memory and CPU time, but there is one but, nginx does not generate dynamic content within yourself, as this will lead to deadlocks within it. The decision has long been: nginx can proxy requests (generating content) on any other Web server: Apache or FastCGI.
Now most of the major sites use nginx + Apache bundle, it is called the frontendbackend (frontend & backend)
How does this bunch?
Let nginx be as the primary server and Apache as a server to generate dynamic content:
Nginx accepts the connection from the client and reads from it the entire query. Once the entire response read nginx, it opens a connection to the Apache. The latter performs its work (generates dynamic content), then gave his answer, nginx, which buffers in memory or a temporary file. Meanwhile, Apache releases resources. Then nginx slowly gives content to the client, without the orders of magnitude less resources than Apache.
How-to implement such chaining will be posted in the following articles.
How to raise something solid? For example, wordpress.
For starters, you need to install all the required components in the system.
Install PHP
In this case, I ograničelsâ a bundle of packages and installed with PHP with govotovoj repov support FastCGI, and did not put out the source. That is also a good option.
Install MySQL

Installing FastCGI
To do this we need to tear out it from another Web server lighttpd note version because if you download the latest version of the server, this is now, and then collect his 1.4.23, do make, and then try to transfer a spawn-cgi in/usr/bin/you have nothing happen, why, the answer is written on the site creators, and looks like this:
Important changes
* Fix workaround for incorrect path info/such if fastcgi prefix is “/ (fixes # 729)
* Finally removed spawn-fcgi
* Fix bug with FastCGI request id overflow under high load; just use always id 1 as we don’t use multiplexing. (thx mcollet)
* Workaround broken operating systems: check for a trailing /‘ in filenames (fixes # 1989)
On this, download version 1.4.19 or earlier.


Here in the Assembly, the program will inform you about the error:
Output, it is necessary to deliver a couple of packages:
Now everything should pass without error:
Use spawn-cgi in/usr/bin/:

Создаем скрипт запуска:

Пишем в него одну строчку:

What does this line mean?
/usr/bin/spawn-fcgi-a run
-p port 90009000
u www-g www www user group www
-f/usr/bin/php5-cgi is the path to your package php5-cgi
If you for some reason is not known, the team which will help. If you are installing from this path, repov.
Create a script to run FastCGI:

В него вставляем следующее

Делаем скрипты исполняемыми:

Запускаем скрипт:

spawn-fcgi.c.197: child spawned successfully: PID: 32477 — подтверждение успешного запуска.

Смотрим таблицу процессов:

А для того, чтобы всё работало после перезагрузки набираем:

You need to be sure that the server is running nginx and PHP in CGI mode
Now that nginx correctly worked with PHP you need to edit the/usr/local/nginx/conf/nginx.conf file by configuring nginx with PHP instead of html.
Here’s how it should look with minimal configuration:

Далее закидываем wordpress в нашу корневую папку:

And type http://localhost/in browser
You will see a window privetsviâ WordPress.
Configuring MySQL. Creation of a database.
Now, all you need is to create a database for the blog.
Remember that MySQL is already installed in the system.
First, you must start the server:
Next, change the password and hold multiple some kind of configuration.
Perform the below written by the command to read all of the options:

Далее выполняем устновку административных таблиц:

Now it’s time to create a table for your blog.
We log into MySQL:
If you saw something similar, then you are logged.
Next, create the table:
CREATE DATABASE statement syntax
db_name is the name that will be assigned to the database.
IF NOT EXISTS if you do not specify this option, if you try to create a database with a name that already exists, you will get an error executing the command.
CHARACTER SET, the COLLATE CLAUSE is used to specify the default encoding table and sort order.
If you create a table, these parameters are not specified, the character set and sort order for the newly created table are taken from the values specified for the entire database. If you specify the CHARACTER SET the COLLATE option is not specified, the default sort order. If the COLLATE option is specified, the CHARACTER SET is not specified, the encoding defines the first part of the name of the sort order in the COLLATE CLAUSE.
To see the settings of an existing database, you must execute the statement SHOW CREATE DATABASE
Here is information about the database that you just created by me:

Завершите работу с mysql выполнив:

Now, it remains in the DATABASE name box in the wordpress installation to specify the name of the database you created and login/password fields specify the user name and password for the MySQL root.
For all SIM! Article and so have huge🙂 Probably and half not reading it to the end. 🙂 I hope someone will be useful.