nginx fastcgi_pass 多个php版本如何替换端口号
nginx 配置:
location ~ \.php$ { fastcgi_pass http://127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } try_files $uri $uri/ /index.php?$query_string;
本地开发 有多个 PHP 版本导致 php-fpm 端口不确定,可以用 unix:+对应的PHP版本的php-cgi-xx.sock; 替换
location ~ \.php$ { fastcgi_pass unix:/tmp/php-cgi-5.6.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } try_files $uri $uri/ /index.php?$query_string;
如何获取sock路径:
macOs 命令行 ps aux | grep php-fpm
找到对应的 php-fpm.conf 打开后看