【发布时间】:2015-07-20 03:28:43
【问题描述】:
我在安装 NginX 时遇到了一些问题。我没有收到任何错误,但是,当我尝试访问我的本地主机地址时,我收到了经典的“500 - 内部服务器错误”。
这是我的配置:
user nobody; ## Default: nobody
worker_processes 5; ## Default: 1
error_log logs/error.log;
pid logs/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include mime.types;
include fastcgi.conf;
index index index.html index.htm index.php;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
server { # simple reverse-proxy
listen 80;
access_log logs/access.log main;
# serve static files
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /Library/Testing/public_html;
expires 30d;
}
# pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://127.0.0.1:8080;
}
}
upstream big_server_com {
server 127.0.0.3:8000 weight=5;
server 127.0.0.3:8001 weight=5;
server 192.168.0.1:8000;
server 192.168.0.1:8001;
}
server { # simple load balancing
listen 80;
server_name big.server.com;
access_log logs/big.server.access.log main;
location / {
proxy_pass http://big_server_com;
}
}
}
有什么问题?我查看了其他相关的 SOF 问题,但没有一个能解决我的问题。谢谢。
编辑:我的日志现在说:2015/07/26 13:43:40 [error] 2494#0: *1 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /index.php HTTP/1.1", upstream: "http://127.0.0.1:8080/index.php", host: "localhost"
当我尝试加载页面“localhost/index.php”时
【问题讨论】:
-
你确定 PHP 没有抛出错误吗? nginx 错误日志中的任何内容?
-
@Will - 如何检查 PHP 错误日志? nginx 似乎没有说什么有用的东西。
-
运行
php --info | grep error。寻找error_log和log_errors。确保log_errors在 php.ini 中打开,并在error_log中指定日志文件的路径。 -
我启用了 log_errors,并且对于 error_log 我设置了默认路径:“php_errors.log” php_errors.log 似乎没有生成。
-
您需要指定错误日志的绝对路径。试试
/var/log/php_errors.log。