# 前言
php-fpm 默认 127.0.0.1:9000, 默认情况下监听端口 9000
另外,也可以使 PHP-FPM 使用 Unix 套接字,这避免了 TCP 的开销
# 参考链接
- https://blog.csdn.net/weixin_29671137/article/details/115513896
# 配置 php-fpm
我的默认配置路径 (根据个人实际情况)
/usr/local/php/etc/php-fpm.conf
/usr/local/php/etc/php-fpm.d/www.conf
## 部分配置 | |
user = www | |
group = www | |
listen = /tmp/php-cgi.sock | |
listen.owner = www | |
listen.group = www | |
listen.mode = 0660 | |
listen.allowed_clients = 127.0.0.1 |
配置完成后重启 php-fpm, 对应路径会生成 /tmp/php-cgi.sock
service php-fpm restart |
# 配置 nginx 站点配置 server
我的默认配置路径 (根据个人实际情况)
/usr/local/webserver/nginx/conf/nginx.conf
/usr/local/webserver/nginx/vhost/www.conf
修改 fastcgi_pass 127.0.0.1:9000; 为 fastcgi_pass unix:/tmp/php-cgi.sock;
## 部分配置 | |
location ~ /(.+\.php)(/.+)*$ { | |
# try_files $uri =404; | |
# rewrite /(.+\.php)(/.+)*$ /hello.html last; | |
# try_files $uri =404; | |
client_max_body_size 10m; | |
fastcgi_pass_header Authorization; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/tmp/php-cgi.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/"; | |
} |
配置完成后重启 nginx
/usr/local/webserver/nginx/sbin/nginx -s reopen |