Home > Operation and Maintenance > Linux Operation and Maintenance > nginx configuration supports php-fpm

nginx configuration supports php-fpm

藏色散人
Release: 2019-05-06 18:48:28
forward
7589 people have browsed it

The following is an introduction to the steps to configure nginx to support php-fpm:

Create a www-data user who cannot log in and belongs to the www-data group

groupadd www-data
useradd -s /sbin/nologin -g www-data www-data
Copy after login

Modify nginx.conf

vim /etc/nginx/nginx.conf
......
#使nginx以www-data用户运行
user  www-data;
......
#重新加载配置
service nginx reload
Copy after login

Modify php-fpm.conf

vim /etc/php-fpm.d/www.conf
......
#使php-fpm以www-data用户和用户组运行
user = www-data
group = www-data
......
#nginx和php-fpm在同一服务器的话,推荐使用unix socket进程间通讯
;listen = 127.0.0.1:9000
listen = /var/run/php71-fpm.sock
......
#设置.sock访问权限,需和nginx用户一致
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
......
#重新加载配置
service php-fpm reload
Copy after login

Configure nginx to support php-fpm

vim /etc/nginx/conf.d/default.conf
......
    location ~ \.php$ {
        root           /usr/share/nginx/html;
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass   unix:/var/run/php71-fpm.sock;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
......
#重新加载配置
service nginx reload
Copy after login

The above is the detailed content of nginx configuration supports php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jmsite.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template