我正在写这个,因为我整晚都试图修复它。
我们最近已经迁移到一个新的服务器。 在迁移之前,我们一直在nginx + cgi(脚本)上运行我们的站点。 迁移后,我们决定尝试apache + mod_php。 这是相当可怕的,我想迁移回nginx,但这次我想用php-fpm(正如人们所说的那样很酷)
所以我确实遵循了一些指南,我想我做的一切正确。 以及我有我的旧的configuration文件的“服务器”部分,我审查和放置到新的configuration。
所以当我input我们的url时,我最终得到了一个空的网站。 (空白我的意思是空白页,没有字母,错误或任何东西。)在访问日志中有一些奇怪的错误,如:
123.242.148.54 – – [22 / Mar / 2012:06:08:11 +0200]“ – ”400 0“ – ”“ –
我的猜测是,PHP-FPM不工作,但不知道如何确认。
也许有些人可以提供一些帮助? 将不胜感激。
我的nginxconfiguration:
user nginx; worker_processes 12; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 4096; } 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 0; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; fastcgi_buffer_size 256k; fastcgi_buffers 4 256k; server { listen 80; server_name www.example.com; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/error.log; root /home/www/example; index index.php; client_max_body_size 50M; #error_page 404 /404.html; # phpMyAdmin location /phpmyadmin { root /usr/share/; error_log /var/log/nginx/phpmyadmin.log; try_files $uri $uri/ /index.php; } location ~ ^/phpmyadmin/.*\.php$ { root /usr/share/; error_log /var/log/nginx/phpmyadmin.log; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; } # Munin location /monitoring { root /var/www/; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/conf.d/monitoring_users; error_log /var/log/nginx/monitoring.log; index index.html; } # The site location / { try_files $uri $uri/ /index.php/?$uri&$args; } # PHP interpreter location ~ \.php { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; } }
如果有错误,你应该检查error.log而不是access.log。
除非你已经在你的fastcgi_params里有这个,你应该加上:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
即你的PHP部分应该看起来像:
# PHP interpreter location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; }