我尝试安装nginx。 我曾经lighttpd,但现在我们必须安装nginx。 你能帮我configurationnginx吗?
我用debian 6.我的nginx.conf:
user www-data; worker_processes 4; 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; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
我的网站启用/默认看起来像
server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www; #! index index.php index.html index.htm; #1 access_log /var/log/nginx/access.log info; error_log /var/log/nginx/error.log info; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html autoindex on; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; }
}
我添加到php.ini中cgi.fix_pathinfo = 0;
php5-cgi以spawn-fcgi运行127.0.0.1 -p 9000 -u www-data -f / usr / bin / php5-cgi
但是我得到502错误(坏的网关)我的/ var / log /说
2012/05/16 15:35:25 [error] 13427#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /ndex.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
请帮忙。
===========================
谢谢你的帮助。 我没有运行sqpwn-fcgi => php-cgi没有监听端口9000。
PHP或者没有运行,或者正在运行,但没有在该套接字上侦听。 检查它是否正在运行ps -eF | grep php ps -eF | grep php ,而且它正在用netstat -tlpn | grep :9000听 netstat -tlpn | grep :9000 。 在/var/log/syslog检查来自PHP的错误消息,或者在/var/log/syslog自己的日志文件。
你看到你的nginx框的错误日志中有错误吗? (可能在/ var / log / nginx /中的某处)这可能有助于发现问题。
–
好吧,我错过了从日志中的部分。 我认为你的fastcgi的configuration是不正确的…