开启目录索引:autoindex on;
1.nginx配置查看sock
1.1 sudo find /etc/php -type f -name '*.conf' -exec grep -H 'listen' {} \;
或
1.2 cat /etc/php/8.1/fpm/pool.d/www.conf
以下内容:
; Note: This value is mandatory.
listen = /var/run/php/php7.4-fpm.sock
可以改为ip端口监听:
listen = 127.0.0.1:9002
server {
listen 80;
server_name www.goserver.com;
# root "E:/projects/www.goserver.com";
location / {
# 设置允许跨域头部
add_header 'Access-Control-Allow-Origin' 'http://www.vuedist.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# cookies跨域传输
add_header 'Access-Control-Allow-Credentials' true;
add_header 'Access-Control-Allow-Headers' 'Origin,x-token, Authorization, Accept, DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# 如果请求方法为 OPTIONS,则直接返回 204 状态码
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'http://www.vuedist.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Origin, Authorization, Accept, DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_pass http://localhost:8869;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
-------------------------------------------------------------
使用try_files指令可以提高性能,因为它允许Nginx直接服务静态文件(如CSS、JavaScript、图片等),而无需将这些请求传递给PHP解释器。这减少了服务器负载并加快了静态资源的加载速度
location / { try_files $uri $uri/ /index.php?$query_string; }
-------------------------------------------------------------
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
1万+

被折叠的 条评论
为什么被折叠?



