下面的配置是 ThinkAdmin 框架的 Nginx 配置,thinkPHP 项目可以通用。
server {
listen 80;
server_name xxx.com;
root /data/PHP/xxx/public;
index index.PHP index.html index.htm;
location / {
try_files $uri $uri/ @rules;
#if (!-e $request_filename) {
# rewrite ^(.*)$ /index.PHP?s=/$1 last;
#}
}
location @rules {
rewrite ^(.*)$ /index.PHP?s=/$1 last;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
#access_log off;
expires 30d;
}
# deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
location ~ /\.ht {
deny all;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.PHP$ {
try_files $uri /index.PHP =404;
fastcgi_pass unix:/run/PHP/PHP7.4-fpm.sock;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
access_log /var/log/Nginx/xxx.com.access.log logstash;
error_log /var/log/Nginx/xxx.com.error.log warn;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。