我有一个rails应用程序(让我们称之为myapp)在www.myapp.com上运行。 我想在www.myapp.com/blog上添加一个WordPress博客。 rails应用程序的web服务器很薄(请参阅上游块)。 wordpress运行php-fastcgi。
导轨应用程序工作正常。 我的问题是以下:在/home/myapp/myapp/log/error.log error我得到:
2013/06/24 10:19:40 [error] 26066#0: *4 connect() failed (111: Connection refused) while connecti\ ng to upstream, client: xx.xx.138.20, server: www.myapp.com, request: "GET /blog/ HTTP/1.1", \ upstream: "fastcgi://127.0.0.1:9000", host: "www.myapp.com"
这里是nginx conf文件:
upstream myapp { server unix:/tmp/thin_myapp.0.sock; server unix:/tmp/thin_myapp.1.sock; server unix:/tmp/thin_myapp2.sock; } server { listen 80; server_name www.myapp.com; client_max_body_size 20M; access_log /home/myapp/myapp/log/access.log; error_log /home/myapp/myapp/log/error.log error; root /home/myapp/myapp/public; index index.html; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; # Index HTML Files if (-f $document_root/cache/$uri/index.html) { rewrite (.*) /cache/$1/index.html break; } if (!-f $request_filename) { proxy_pass http://myapp; break; } # try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby; } location /blog/ { root /var/www/wordpress; fastcgi_index index.php; if (!-e $request_filename) { rewrite ^(.*)$ /blog/index.php?q=$1 last; } include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name; fastcgi_pass localhost:9000; # port to FastCGI } }
任何想法,为什么这是行不通的? 我如何确保php-factcgiconfiguration正确?
编辑:我不能testing如果fastcgi运行与远程login:
$> telnet 127.0.0.1 9000 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
事实并非如此。
php-fpm没有运行。 刚开始
问题的根源在于php-fpm没有运行(就像@Michael指出的那样)
我还更改了位置块,因为资源没有与原始configuration一起提供:
location ^~ /blog { root /var/www/wordpress; index index.php index.html index.htm; try_files $uri $uri/ /blog/index.php?$args; location ~ \.php$ { include /etc/nginx/fastcgi_params; #if ($uri !~ "^/images/") { # fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; #} fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/wordpress$fastcgi_script_name; fastcgi_pass localhost:9000; } }