我是nginx的新手,我无法确定为什么我的nginx配置无法按预期工作.我想要做的就是让每个web根(/)请求的index.php上的nginx优先化index.html.
这是我的nginx配置:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
multi_accept on;
}
http {
##
# Basic Settings
##
server {
location / {
index index.html index.php;
}
location ~ \.php$ {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
sendfile on;
tcp_nopush on;
tcp_nodelay off;
keepalive_timeout 15;
keepalive_requests 100000;
types_hash_max_size 2048;
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
----------------- cut ---------------
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Run Code Online (Sandbox Code Playgroud)
哪里是我的错误?编写这个nginx配置的正确方法是什么?
如果您明确请求/index.html,是否提供服务?如果没有,你可能要一个明确的添加root /path/to/root;到您的server {}块.还要验证index.html是否具有正确的权限.
这将有助于排除故障:如果找不到根index.html,它将强制404.如果发生这种情况,至少可以检查日志以查看它是否正在寻找:
location = / {
index index.html;
}
Run Code Online (Sandbox Code Playgroud)
此外,请务必nginx -s reload在更改配置时执行此操作.
| 归档时间: |
|
| 查看次数: |
18532 次 |
| 最近记录: |