Home > Article > Operation and Maintenance > nginx configuration supports php-fpm
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
Modify nginx.conf
vim /etc/nginx/nginx.conf ...... #使nginx以www-data用户运行 user www-data; ...... #重新加载配置 service nginx reload
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
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
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!