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 $uri/ /public/index.php?$query_string;
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_index index.php;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:7777;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
나는 다음을 시도했습니다 :
chown -R www-data /var/www/app/my-app
아무런 차이가 없는 권한을 설정하세요.- 오류 또는 지원을 변경하지 않은
alias
및 디렉토리 조정try_file
답변1
$uri/
이 오류는 nginx에 /var/www/app/my-app/ 디렉터리의 콘텐츠를 제공하도록 지시하는 try_files 절의 일부로 인해 발생합니다 . 디렉토리 목록은 기본적으로 금지되어 있으며 autoindex on;
위치에 추가하여 활성화할 수 있습니다 .
/var/www/app/my-app/public/index.php 파일이 존재하지 않는 것 같습니다.