在 Debian 8.6 虚拟机上设置 nginx 1.10.1 - 服务器块(vhost)问题

在 Debian 8.6 虚拟机上设置 nginx 1.10.1 - 服务器块(vhost)问题

大家好,大家好。首先,感谢您抽出时间来审阅并回答我的问题。非常感谢。

我或多或少在一个新的虚拟机(Google Cloud Computing)上设置了一切,并尝试使用 Debian、nginx、mariadb 和 php。

过去,我曾多次在虚拟机上完成这种类型的设置,但这次我决定获取最新版本的 nginx(1.10.1),而不是在输入 apt-get install nginx 时使用 Debian 的默认软件包,而无需更新源列表。(我相信那个是 1.6.3)。

虽然两者之间的差异很小,但我注意到的一件事是,此版本的 nginx 不使用 /sites-enabled/ 和 /sites-available/ 文件夹作为服务器块 (Vhosts),而是直接转到 /etc/nginx/conf.d/ 文件夹。我想,没问题。

现在我的情况是,我正在处理的网站 organiplan dot com 显示 404 页面未找到,尽管我的服务器块和 nginx.conf 文件似乎已正确设置。我将在下面包含这两者。

服务器块

 server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

root /var/www/html/organiplan.com/public_html;
index index.php index.html index.htm;

server_name organiplan.com www.organiplan.com;

client_max_body_size 1024m;

location / {
try_files $uri $uri/ /index.php?q=$request_uri;
   }

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
   }

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
   }
}

nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
worker_connections  1024;
}


http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

include /etc/nginx/conf.d/*.conf;
}

尽管 index.php 和 index.html 文件都位于指定的根目录中,它仍然显示 404 未找到。我知道我肯定错过了一些非常明显的东西,但我还没能弄清楚。甚至清除了服务器并重新安装了所有内容,以确保我没有弄乱我没有注意到的东西,结果还是一样。

提前感谢提供的任何帮助。我非常感激。

编辑

抱歉,我不知道为什么我没有想到在最初的帖子中包含错误日志。下面您将找到 nginx error.log 和 php5-fpm.log

nginx 错误日志

[error] 26954#26954: *86 open() "/usr/share/nginx/www/50x.html" failed (2:   No such file or directory), client: 66.249.64.66, server: organiplan.com,  request: "GET /tag/php/feed/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5- fpm.sock", host: "organiplan.com"
2016/09/21 00:21:27 [crit] 26954#26954: *89 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 66.249.64.125, server: organiplan.com, request: "GET /tag/tag/feed/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "organiplan.com"
2016/09/21 00:21:27 [error] 26954#26954: *89 open() "/usr/share/nginx/www/50x.html" failed (2: No such file or directory), client: 66.249.64.125, server: organiplan.com, request: "GET /tag/tag/feed/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock", host: "organiplan.com"

php5-fpm.log

20-Sep-2016 17:33:41] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf     test is successful

[20-Sep-2016 17:33:42] NOTICE: fpm is running, pid 22891
[20-Sep-2016 17:33:42] NOTICE: ready to handle connections
[20-Sep-2016 17:33:42] NOTICE: systemd monitor interval set to 10000ms
[20-Sep-2016 17:33:49] NOTICE: Terminating ...
[20-Sep-2016 17:33:49] NOTICE: exiting, bye-bye!
[20-Sep-2016 17:33:49] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf          test is successful

[20-Sep-2016 17:33:49] NOTICE: fpm is running, pid 23151
[20-Sep-2016 17:33:49] NOTICE: ready to handle connections
[20-Sep-2016 17:33:49] NOTICE: systemd monitor interval set to 10000ms 
[20-Sep-2016 17:33:50] NOTICE: Terminating ...
[20-Sep-2016 17:33:50] NOTICE: exiting, bye-bye!
[20-Sep-2016 17:33:50] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

[20-Sep-2016 17:33:50] NOTICE: fpm is running, pid 23431
[20-Sep-2016 17:33:50] NOTICE: ready to handle connections
[20-Sep-2016 17:33:50] NOTICE: systemd monitor interval set to 10000ms

答案1

错误日志显示访问 PHP 的权限不正确。修复该问题后,我希望一切将开始正常工作,前提是没有其他错误配置。

建议您查看 PHP 套接字的路径、用户、组和权限。它真的在下面的路径中吗?运行 Nginx 的用户是否具有该路径的权限?

/var/run/php5-fpm.sock

相关内容