nginx配置问题
nginx配置如下。访问首页http://127.0.0.1:8090时会直接下载入口文件,很奇怪。
但是访问http://127.0.0.1:8090/index.php可以正常进入welcome页面。
请问我哪里配错了吗。laravel版本:Laravel Framework 8.9.0
server {
listen 8090;
listen [::]:8090;
server_name localhost;
root /data/html/laraLearn/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /data/html/letsencrypt/;
log_not_found off;
}
error_log /usr/local/nginx/logs/lara_error.log;
access_log /usr/local/nginx/logs/lara_access.log;
}
1 Comment
首先确保 nginx 虚拟主机配置目录下的 default 有没有删除 那里面域名也是 localhost
然后抄官方文档里面提供的 Nginx 配置就好了:https://xueyuanjun.com/post/21963#toc-2,域名路径替换成自己的,很明显你这一行配错了: