Saya sudah menginstal nginx via Homebrew di Mac saya. Baru-baru ini saya mencoba menambahkan server php virtual. Ini berfungsi dengan baik ketika saya mengakses nama file yang benar, tetapi memberikan kesalahan izin ketika blok try akan dipanggil atau file indeks harus dilayani.
#200 :
http://php-sandbox.dev/index.php
#404 :
http://php-sandbox.dev/index
http://php-sandbox.dev/
File index.php ada di direktori web root dan memiliki 744 izin seperti halnya semua folder di jalurnya.
Arahan indeks tampaknya diabaikan. Lihat contoh dan kesalahan di bawah ini serta konfigurasi nginx saya.
File konfigurasi situs untuk nginx: server {listen 80; dengarkan [::]: 80; error_log /var/log/nginx/php-sandbox/error.log debug; rewrite_log aktif;
server_name php-sandbox.dev;
root /Users/sswright/repos/jswright61/php-sandbox/public;
index index.php index.html;
include drop.conf; #ignores favicons
location / {
try_files $uri $uri.php $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
Log kesalahan: (/ diminta)
2017/04/23 09:47:15 [crit] 11149#0: *9 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET / HTTP/1.1", host: "php-sandbox.dev"
2017/04/23 09:47:15 [crit] 11149#0: *9 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/.php" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET / HTTP/1.1", host: "php-sandbox.dev"
2017/04/23 09:47:15 [crit] 11149#0: *9 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET / HTTP/1.1", host: "php-sandbox.dev"
Blok try sedang dijalankan, tetapi indeks tidak sedang dicoba.
Log kesalahan: (/ indeks diminta)
2017/04/23 10:11:40 [crit] 11149#0: *12 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/index" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET /index HTTP/1.1", host: "php-sandbox.dev"
2017/04/23 10:11:40 [crit] 11149#0: *12 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET /index HTTP/1.1", host: "php-sandbox.dev"
2017/04/23 10:11:40 [crit] 11149#0: *12 stat() "/Users/sswright/repos/jswright61/php-sandbox/public/index" failed (13: Permission denied), client: 127.0.0.1, server: php-sandbox.dev, request: "GET /index HTTP/1.1", host: "php-sandbox.dev"
Ini dia mencari index.php tetapi mendapatkan kesalahan izin. Ketika /index.php diminta, halaman dimuat dengan benar.
/index
harus menyebabkannya mengunduhindex.php
. Apakah Anda yakin ini adalahnginx
konfigurasi saat ini ? Cobalah menggunakannginx -T