【发布时间】:2018-08-19 22:38:35
【问题描述】:
第一次这样做。自从我遇到这个问题两天后,还没有找到问题所在。
我在EC2 上的Ubuntu 18.04 实例上安装了laravel。该项目在我当地的Homestead 环境中运行良好。经过与权限的斗争,我现在被nginx/laravel提供的空白页面困住了。
我希望设置权限,以便用户ubuntu 可以从BitBucket 部署更新,而www-data 可以运行Laravel 应用程序。
我被困住了,因为我似乎无法找到记录/发生错误的位置。
几点;
网站的
nginx错误日志中没有错误Nginx在站点的访问日志中显示 HTTP 200 响应代码我的
.env文件中有APP_DEBUG=true用于详细堆栈跟踪,但没有显示任何内容laravel.log中没有显示错误如果我将 URL 指向 img 文件夹内的徽标文件,浏览器将提供网站的徽标
我根据this answer设置文件夹权限
/project =
Laravel's根文件夹/project/public =
nginx网络根目录
我的项目文件夹权限设置如下:
sudo chown -R www-data:www-data /project
sudo usermod -a -G www-data ubuntu
sudo chown -R ubuntu:www-data /project
sudo find /project -type f -exec chmod 664 {} \;
sudo find /project -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
我的nginx 配置是:
server {
server_name project.com.au www.project.com.au;
root /home/ubuntu/project/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
access_log /var/log/nginx/sc.access.log;
error_log /var/log/nginx/sc.error.log error;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/project.com.au/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/project.com.au/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.project.com.au) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = project.com.au) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name project.com.au www.project.com.au;
return 404; # managed by Certbot
}
第二个server 部分由letsencrypt / Cert-Bot 添加。
我的public文件夹的文件列表是:
-rw-r--r--+ 1 ubuntu www-data 281 Aug 16 16:02 browserconfig.xml
drwxr-xr-x+ 2 ubuntu www-data 4096 Aug 16 10:46 css
-rw-r--r--+ 1 ubuntu www-data 1150 Aug 16 16:02 favicon.ico
drwxr-xr-x+ 2 ubuntu www-data 4096 Aug 16 16:02 fonts
drwxr-xr-x+ 3 ubuntu www-data 4096 Aug 16 16:02 img
-rw-r--r-- 1 ubuntu www-data 1823 Aug 16 16:36 index.php
drwxr-xr-x+ 2 ubuntu www-data 4096 Aug 16 10:46 js
-rw-r--r--+ 1 ubuntu www-data 720 Aug 16 16:02 manifest.json
-rw-r--r-- 1 ubuntu www-data 192 Aug 16 16:02 mix-manifest.json
-rw-r--r-- 1 ubuntu www-data 24 Aug 16 15:28 robots.txt
-rw-r--r-- 1 ubuntu www-data 914 Aug 16 15:28 web.config
我的nginx 访问和错误日志没有任何条目/
我的项目错误日志为空。我的项目访问日志显示:
27.99.0.231 - - [19/Aug/2018:13:33:05 +0000] "GET / HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
我的主页是空白的,没有nginx 错误或laravel 堆栈跟踪。如果我将/img/logo.png 添加到基本 URL,则徽标会显示在页面中。
我还能去哪里看?所有研究都指向上面的 conf 文件,但我没有发现任何异常。
【问题讨论】: