mac 通过brew安装的nginx和php,部署不同网站使用不同的php版本
max系统 brew安装 nginx 多个版本php
直接上配置:
nginx的虚拟机配置,有也就是一个server:
/opt/homebrew/etc/nginx/servers/wycto-admin.conf
server {
listen 8080;
server_name www.wycto-admin.me;
root /Users/data/gitee/wycto-admin/public;
index index.php index.html index.htm;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
location ~* (runtime|application)/{
return 403;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-cgi-81.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
access_log /Users/data/gitee/wycto-admin/web.log;
error_log /Users/data/gitee/wycto-admin/web.error.log;
}
php配置注意点是上面的unix:/tmp/php-cgi-81.sock;
/opt/homebrew/etc/php/8.1/php-fpm.d/www.conf
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]
;listen = 127.0.0.1:9000
listen = /tmp/php-cgi-81.sock
把listen改为 /tmp/php-cgi-81.sock, 如果使用IP和端口的话,每个版本都要换端口,且 fastcgi_pass unix:/tmp/php-cgi-81.sock; 改为 127.0.0.1:9000; 127.0.0.1:9001 ;127.0.0.1:9002。这样
请先登录后再评论登录