我試圖設置我的laravel爲nginx。我的配置:爲nginx設置laravel(錯誤與權限被拒絕)
server {
listen 80;
server_name decoder.lan;
root /var/www/decoder-now/public;
index index.php;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location @php { ## Depending on your Nginx version, you might need to change this to location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @handler {
rewrite//index.php;
}
}
我得到錯誤error.log中:
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [crit] 14063#0: *10 stat() "/var/www/decoder-now/public/index.php" failed (13: Permission denied), client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
2014/11/24 15:13:43 [error] 14063#0: *10 rewrite or internal redirection cycle while redirect to named location "@rewrite", client: 127.0.0.1, server: decoder.lan, request: "GET /address/ HTTP/1.1", host: "decoder.lan"
這個例子與網址的工作:decoder.lan /地址,但decoder.lan /不是工作壓力太大。
access.log文件:
127.0.0.1 - - [24/Nov/2014:15:13:43 +0300] "GET /address/ HTTP/1.1" 500 603 "-" "Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36"
我試圖檢查的工作聽或不這個文件。我從控制檯檢查這個由命令:
sudo -u www-data cat index.php
從控制檯文件被打開了。
我使用www數據的用戶,因爲在/ect/php5/fpm/pool.d/www.conf我有:
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
文件列表... /解碼器現在/公/文件夾:
-rwxr-xr-x 1 www-data www-data 2238 нояб. 17 19:01 favicon.ico
-rwxrwxrwx 1 www-data www-data 1586 нояб. 17 19:01 index.php
drwxr-xr-x 2 www-data www-data 4096 нояб. 17 19:01 packages
-rwxr-xr-x 1 www-data www-data 24 нояб. 17 19:01 robots.txt
在這個實例中,我曾經工作過Apache服務器,但他在這一刻斷電了。所有請求都在nginx服務器上。
請幫助我,我的英語不好:)
謝謝!它的工作,但我有新的錯誤:[暴擊] 25475#0:* 1 stat()「/ var/www /解碼器 - 現在/公共/」失敗(13:權限被拒絕)[錯誤] 25475#0:* 1 connect()失敗(111:連接被拒絕),同時連接到上游,客戶端:127.0.0.1,server:decoder.lan,請求:「GET/HTTP/1.1」,上游:「fastcgi://127.0.0.1:9001」我嘗試更改端口:9000到9001,但它不再工作 – Roman 2014-11-24 14:20:02
我通常將nginx用戶添加到www數據組。這可能會解決您的權限問題。使用此命令:sudo usermod -a -G www-data nginx – 2014-11-24 14:22:39
此外,如果您的php.ini設置爲使用IP地址,則需要更新配置文件中的fastcgi_pass行,因爲它使用的是unix sock。 – 2014-11-24 14:23:46