Current location - Quotes Website - Collection of slogans - How to modify the running user of php-fpm
How to modify the running user of php-fpm
The first type: a php-fpm main process.

This method is relatively simple, and only a php-fpm self-starting file is needed.

First of all, let's take a look at this configuration file of the original php-fpm.conf, which is divided into two parts, one is a global block and the other is a user-defined block. The configuration file is called pool, which is called "www" by default. At the top of the global pool, there is a line of comments "include=etc/fpm.d/*. Conf "configuration item, and then through the configuration of www pool, we know that different users can be configured through different pools to achieve the purpose of running php-fpm by multiple users. The steps are as follows:

4. Delete the previous global block or comment it out.

5. Change [www] to something else, such as your [blog].

6. Configure the [blog] pool, and mainly modify two places:

6. 1: The first place is the running user and user group.

fast

12user = www3group = www4 .

be revised as

12user=nobody # Which user to use to see your own situation. I only give an example of 3group=nobody4.

6.2: Modify the monitored port or socket:

Coming soon:

12 listen = 127 . 0 . 0 . 1:90003 .

Revised as:

12listen =/var/socket/PHP-fpm/blog.socket # PHP-fpm needs to be created by itself, or it can be directly placed in the PHP-fpm directory.

It can also be modified to other ports, such as: listen =127.0.0.1:9001.

7. Go to the main configuration file php-fpm.conf and delete the comment before "include=…" so that it can read the configuration file in the fpm.d directory.

8. At this point, the first scheme has been modified. Restart the test:

12 service php-fpm reload 3.

The second type: two php-fpm main processes.

This method requires independent configuration files and independent startup files:

1. Copy a master configuration file of php-fpm.conf

12c PHP-fpm . conf PHP-fpm-blog . conf 3 .

2. Modify the master configuration file.

12vim php-fpm-blog.conf3 .

2. 1: modify the path of pid and error_log files under Global.

Modify pid=run/php-fpm.pid to PID = run/PHP-fpm-blog.pid.

Modify error_log = /log/php-fpm.log to error _ log =/log/PHP-fpm-blog.log.

2.2: Change the pool name [www] to [blog], but this need not be changed because it is independent of the original process.

2.3: Modify users and user groups.

2.4: Listen to port or socket files.

The above two parts can be modified according to the first scheme, and will not be described here.

3. Enter the /etc/init.d directory and copy a self-starting file.

12cp。

4. Modify the startup file php-fpm2:

4. 1: Modify the configuration file path.

12 PHP _ fpm-CONF = $ { prefix }/etc/PHP-fpm . conf 3 .

for

12 PHP _ fpm-CONF = $ { prefix }/etc/PHP-fpm-blog . conf 3 .

This path is the main configuration file just now.

4.2: Modify PID file path:

12 PHP _ fpm _ PID = $ { prefix }/var/run/PHP-fpm . PID 3 .

Used for:

12 PHP _ fpm _ PID = $ { prefix }/var/run/PHP-fpm-blog . PID 3 .

This path should be consistent with the pid path in the main configuration file.

5. Automatically start after adding and modifying.

12 chk config-add PHP-fpm 23 chk config-level 2345 PHP-fpm 2 on 4 .

6. Start the service.