Trying to install wordpress inside rails app with nginx and fastcgi

Posted by pinouchon on Server Fault See other posts from Server Fault or by pinouchon
Published on 2013-06-24T08:39:49Z Indexed on 2013/06/24 16:25 UTC
Read the original article Hit count: 418

Filed under:
|
|
|

I have a rails app (let's call it myapp) running at www.myapp.com. I want to add a wordpress blog at www.myapp.com/blog. The webserver for the rails app is thin (see the upstream block). The wordpress runs with php-fastcgi.

The rails app works fine. My problem is the following: in /home/myapp/myapp/log/error.log error I get:

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"

Here is the nginx conf file:

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                                           
         }

}

Any ideas why that doesn't work ? How do I make sure that php-factcgi is configured properly ?

Edit: I cant test if fastcgi is running with telnet:

$> telnet 127.0.0.1 9000
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

And it's not.

© Server Fault or respective owner

Related posts about nginx

Related posts about ruby-on-rails