我有一个带有centos 7的流浪盒
config.vm.box = "centos/7"
我有php 7.1和配置的nginx网站(Symfony 3)。问题是,当我访问该网站时,我收到此错误:
File not found.
检查nginx日志我发现了这个:
2017/02/25 15:04:19 [error] 15763#15763: *5 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.56.1, server: site.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "site.dev"
Nginx作为www-data用户运行:
www-data 15763 0.0 0.1 46292 3216 ? S 13:16 0:00 nginx: worker process
我虽然这可能与权限问题有关,但我检查了vhost文件根目录的文件权限,我发现所有者是用户“游戏”wtf?
drwxr-xr-x. 8 501 games 272 feb 25 10:28 .
drwxr-xr-x. 19 501 games 646 feb 25 12:08 ..
-rwxr-xr-x. 1 501 games 1189 feb 25 10:28 app_dev.php
-rwxr-xr-x. 1 501 games 2092 feb 25 10:28 apple-touch-icon.png
-rwxr-xr-x. 1 501 games 631 feb 25 10:28 app.php
-rwxr-xr-x. 1 501 games 21486 feb 25 10:28 config.php
-rwxr-xr-x. 1 501 games 6518 feb 25 10:28 favicon.ico
-rwxr-xr-x. 1 501 games 116 feb 25 10:28 robots.txt
但如果我尝试做一个chown,我会得到一个不允许错误的操作。
这是vhost配置文件:
server {
listen 80;
server_name {{www_domain}};
return 301 https://{{www_domain}}$request_uri;
}
server {
listen 443 ssl;
server_name {{www_domain}};
root {{www_document_root}};
ssl_certificate /etc/nginx/ssl/ssl_certificate.crt;
ssl_certificate_key /etc/nginx/ssl/ssl_certificate.key;
client_max_body_size 50M;
access_log /var/log/nginx/{{www_domain}}.access.log;
error_log /var/log/nginx/{{www_domain}}.error.log error;
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
## Static files are served directly.
location \/images\/(.*)$ {
expires max;
log_not_found off;
access_log off;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=1000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
}
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_intercept_errors on;
}
}
答案 0 :(得分:0)
好的,我在这几个小时内遇到了这个确切的问题而且找不到解决方案直到我切换到另一个流浪盒并且它神奇地开始工作。
我现在使用的是config.vm.box = "bento/centos-7.3"
而不是centos/7
。
我不知道盒子之间有什么区别。如果有人能告诉我为什么一个有效,另一个没有,那么我很想知道。
答案 1 :(得分:0)
问题是SELINUX
,因为我运行此命令可以解决问题
$ setenforce 0
$ sed -i 's/SELINUX=\(enforcing\|permissive\)/SELINUX=disabled/g' /etc/selinux/config