Introduction to the organizational structure of the nginx+ php fpm configuration file

  • 2020-05-26 08:08:26
  • OfStack

1. Configuration file path for nginx
1 a, install nginx, the default configuration file path is/usr local nginx/conf/nginx conf.
We can use a link file to point the conf directory to a specific directory for easy management. Like, for example, the author company focuses all of the server configuration file in/home server_config, then build a subdirectory in the directory nginx, then/usr local nginx/conf through/home server_config/nginx link file pointing to.

2. Configuration file path for Virtual host
Typically, my company writes each Virtualhost profile into a separate file. These separate files are separate in different projects.

But a trick is to create a subdirectory, include, in the directory where nginx.conf is located. In the directory include, include is a series 1 link file that points to the configuration files of Virtualhost.

3. Configuration file path for php-fpm
Typically, the php-fpm executable is in the sbin directory under the php installation path. (here, as an aside, when installing php, the installation directory 1 generally defaults to /usr/local, which is not a good choice, since sometimes multiple versions of php may need to exist on one server at a time. A good implementation is to install different versions of php in /usr/local/ php-xxx /, with xxx representing the version of php).
The php-fpm configuration file is placed by default in the etc directory under the php installation path. But in fact, the configuration file for php-fpm can specify the path when php-fpm is started, and different instances of php-fpm can specify different configuration files. This is also of practical significance: on a single server, Nginx may be listening to multiple VirtualHost at the same time. When you restart an Host, you only need to restart the corresponding php-fpm instance.

4. Configuration file paths for each pool
You can specify that. But basically, we're going to centralize it. My company chose to put it under /var/run and build a folder for each instance. Besides php-fpm, the folder will also put the corresponding pid files and the corresponding unix:socket files.

Related articles: