尝试在 Ubuntu+Nginx 服务器上加载我的 Laravel 应用程序时,我不断遇到此错误。
用户应该访问app.example.com/my-app
它应该加载的内容/var/www/app/my-app/public/index.php
[错误] 9028#0:*15001 目录索引“/var/www/app/my-app/”被禁止,客户端:xxx.xxx.xxx.xx,服务器:app.example.com,请求:“GET /my-app/ HTTP/1.1”,主机:“app.example.com”
我的 nginx 配置如下:
server
{
server_name app.example.com www.app.example.com;
root /var/www/app;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$
{
#fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
fastcgi_pass 127.0.0.1:7777;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~ /\.ht
{
deny all;
}
location /my-app/{
alias /var/www/app/my-app/public/;
try_files $uri …
Run Code Online (Sandbox Code Playgroud)