Nginx网站的PHP脚本提供404的所有网页链接
我在nginx上有一个网站,它是一个用于图像站点的php脚本 问题是,每当我点击主页上的链接,它就会给我一个404。 我可以访问主页,它显示最后的图像,我可以访问和使用管理面板,所以脚本或它的安装不是问题 我相信问题出在我的nginx.conf文件上,但这是我第一次使用它,我找不到问题。 我很确定这在http方面很简单 有人知道问题出在哪里吗 我附上nginx.confNginx网站的PHP脚本提供404的所有网页链接,php,nginx,Php,Nginx,我在nginx上有一个网站,它是一个用于图像站点的php脚本 问题是,每当我点击主页上的链接,它就会给我一个404。 我可以访问主页,它显示最后的图像,我可以访问和使用管理面板,所以脚本或它的安装不是问题 我相信问题出在我的nginx.conf文件上,但这是我第一次使用它,我找不到问题。 我很确定这在http方面很简单 有人知道问题出在哪里吗 我附上nginx.conf user www-data; worker_processes 5; pid /var/run/nginx.pid; eve
user www-data;
worker_processes 5;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
index index.php;
##Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
我为相关站点添加已启用的站点和可用的站点文件
站点启用文件
server {
listen *:80;
server_name MYSITE.com ;
root /var/www/MYSITE.com/web;
index index.php;
location ~ \.shtml$ {
ssi on;
}
error_log /var/log/ispconfig/httpd/MYSITE.com/error.log;
access_log /var/log/ispconfig/httpd/MYSITE.com/access.log combined;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client0/web1/web/stats/.htpasswd_stats;
}
location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}
location ~ \.php$ {
try_files /446853f6175b4ee703d1115b71d6c0c9.htm @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
location /cgi-bin/ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
root /var/www/clients/client0/web1;
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
站点可用文件
server {
listen *:80;
server_name MYSITE.com ;
root /var/www/MYSITE.com/web;
index index.php;
location ~ \.shtml$ {
ssi on;
}
error_log /var/log/ispconfig/httpd/MYSITE.com/error.log;
access_log /var/log/ispconfig/httpd/MYSITE.com/access.log combined;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /stats {
index index.html index.php;
auth_basic "Members Only";
auth_basic_user_file /var/www/clients/client0/web1/web/stats/.htpasswd_stats;
}
location ^~ /awstats-icon {
alias /usr/share/awstats/icon;
}
location ~ \.php$ {
try_files /446853f6175b4ee703d1115b71d6c0c9.htm @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/web1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
location /cgi-bin/ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
root /var/www/clients/client0/web1;
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
我将/var/log/ispconfig/httpd/MYSITE.com/error.log的最后几行添加到我的帖子中。
(编辑域是件痛苦的事,所以我将把它留在那里,稍后再编辑问题)
你的网站是wordpress网站吗?了解您正在运行的php应用程序将有助于人们向您提供更准确的反馈 仅根据您的站点配置和描述
try_files$uri=404代码>以下位置@php
位置~\.php$
之前添加以下行:
location / {
try_files $uri =404;
}
HTH您是否递归设置了文件权限?我想是的。所有目录都是755,所有文件都是644(除了需要777才能运行脚本的两个文件夹),但它仍然为所有onpage链接提供404。我刚刚检查了错误日志,我看到了这个。2013/08/27 04:25:37[错误]29071#0:*555 open()“/var/www/MYSITE.com/web/FAILEDURL”失败(2:没有这样的文件或目录),客户端:190.193.156.31,服务器:MYSITE.com,请求:“GET/FAILEDURL HTTP/1.1”,主机:“MYSITE.com”,参考者:“请共享虚拟主机配置文件,而不是nginx,那些通常在
站点中启用的
和站点可用的
只是尝试了一下(启用站点上的更改,不起作用,删除了更改,使站点上的更改可用,不起作用,删除了更改),在这些更改之后尝试进入主页时,我得到了404。删除后,主页和管理面板再次开始工作(我仍然无法点击任何onpage链接,因为我得到了404)。该网站不是wordpress网站。这是一个php上用于图像站点的脚本。这可能是一个愚蠢的问题,但在更改配置文件后是否重新启动了nginx?此外,站点中启用的内容应该只是指向可用站点中文件的符号链接。如果更改后没有任何变化,您能否将最后20行/var/log/ispconfig/httpd/MYSITE.com/error.log发布到您的主帖子中?我已将最后20行日志添加到主帖子中。每次更改后,我都会重新启动nginx。我不知道如何回答符号链接问题。除了apple-touch-icon.png/apple-touch-icon-precomposed.png外,日志中的任何请求都不像是图像请求
location / {
try_files $uri =404;
}