Home  >  Article  >  Backend Development  >  How to modify php-fpm user

How to modify php-fpm user

藏色散人
藏色散人Original
2022-01-21 09:49:252282browse

How to modify the php-fpm user: 1. Modify "user = test group = test"; 2. Modify the permissions of "php7.0-fpm.pid" and "php7.0-fpm.sock" ;3. Restart php-fpm.

How to modify php-fpm user

The operating environment of this article: Windows7 system, PHP7.0 version, DELL G3 computer

How to modify the php-fpm user?

Modify php-fpm and nginx running users:

(php) project a is run with test user

nginx and php- fpm is run by the www-data user

(python) Project b is run by the test user

Project a calls the python script interface through the php function exec, resulting in no permission to access the directory

Directly switching the permissions of project b to www-data can be executed, but it is not convenient for development. It is best to put php, nginx, project a, and project b under the same user and group.

For example, test is the currently logged in user

Modify the running role of nginx

cd /etc/nginx
sudo vi nginx.conf
# 头部是这样
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
# 修改为
user test;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
# 重启nginx
sudo service nginx restart

Modify the running role of php

cd /etc/php/7.0/fpm/pool.d/
sudo vi www.conf
# 找到
user = www-data
group = www-data
# 改为
user = test
group = test
cd /run/php/
ls -al
# 这个目录下面有两个文件
# php7.0-fpm.pid和php7.0-fpm.sock
# 修改这两个文件的权限
sudo chown test:test php7.0-fpm.pid
sudo chown test:test php7.0-fpm.sock
# 重启php-fpm
sudo service php7-fpm restart

The test user is made up Modify

according to your current user Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to modify php-fpm user. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn