Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My site is running on apache. two instances of wordpress exist under paths /tr/ and /eng/. I want to move the setup to nginx but could not manage to get it working.

My setup consists of nging 0.7.66, php 5.3.2, and php-fpm. /tr/ and /eng/ are two separate wordpress instances located under /home/istci/webapps/wordpress_tr and /home/istci/webapps/wordpress respectively.

Below is the server section from nginx.conf containing only configuration for tr, yet could not get it working either.

server {
    listen       80;
    server_name  www.example.com;

    charset utf-8;

    location ~ ^/$ {
        rewrite ^(.+)$ http://www.example.com/tr/ permanent;
    }

    location ~ /tr/.*php$ {
        fastcgi_pass   unix:/home/istci/var/run/wptr.sock; 
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    /home/istci/webapps/wordpress_tr$fastcgi_script_name;

        fastcgi_param  QUERY_STRING       $query_string;
        fastcgi_param  REQUEST_METHOD     $request_method;
        fastcgi_param  CONTENT_TYPE       $content_type;
        fastcgi_param  CONTENT_LENGTH     $content_length;

        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param  REQUEST_URI        $request_uri;
        fastcgi_param  DOCUMENT_URI       $document_uri;
        fastcgi_param  DOCUMENT_ROOT      $document_root;
        fastcgi_param  SERVER_PROTOCOL    $server_protocol;

        fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
        fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

        fastcgi_param  REMOTE_ADDR        $remote_addr;
        fastcgi_param  REMOTE_PORT        $remote_port;
        fastcgi_param  SERVER_ADDR        $server_addr;
        fastcgi_param  SERVER_PORT        $server_port;
        fastcgi_param  SERVER_NAME        $server_name;

        # required if PHP was built with --enable-force-cgi-redirect
        fastcgi_param  REDIRECT_STATUS    200;
    }


    location /tr/ {
        root   /home/istci/webapps/wordpress_tr/;
        index  index.php index.html index.htm;


        if (!-e $request_filename) {
            rewrite ^(.+)$ /tr/index.php?q=$1 last;
            break;
        }

        if (-f $request_filename) {
            expires 30d;
            break;
        }

    }
}

php-fpm listens on unix:/home/istci/var/run/wptr.sock. running it in debug-mode shows no active handlers, which means no connection is made to unix socket from nginx.

nginx access logs:

127.0.0.1 - - [09/Jun/2010:03:45:11 -0500] "GET /tr/ HTTP/1.0" 404 20 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.4) Gecko/20100527 Firefox/3.6.4"

nginx debug logs :

2010/06/09 03:38:53 [notice] 6922#0: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)
2010/06/09 03:38:53 [notice] 6922#0: OS: Linux 2.6.18-164.9.1.el5PAE
2010/06/09 03:38:53 [notice] 6922#0: getrlimit(RLIMIT_NOFILE): 4096:4096
2010/06/09 03:38:53 [notice] 6923#0: start worker processes
2010/06/09 03:38:53 [notice] 6923#0: start worker process 6924
2010/06/09 03:38:53 [notice] 6923#0: start worker process 6925
2010/06/09 03:39:01 [notice] 6925#0: *1 "^(.+)$" matches "/tr/", client: 127.0.0.1, server: www.example.com, request: "GET /tr/ HTTP/1.0", host: "www.example.com"
2010/06/09 03:39:01 [notice] 6925#0: *1 rewritten data: "/tr/index.php", args: "q=/tr/", client: 127.0.0.1, server: www.example.com, request: "GET /tr/ HTTP/1.0", host: "www.example.com"

Any clues about what is wrong with my configuration? Thanks.

share|improve this question

migrated from stackoverflow.com Jun 9 '10 at 13:39

This question came from our site for professional and enthusiast programmers.

    
serverfault.com/questions/417357/… –  quanta Aug 31 '12 at 11:20

1 Answer 1

read about try_files

location /tr {
    try_files $uri $uri/ /tr/index.php;
}
location /eng {
    try_files $uri $uri/ /eng/index.php;
}

add this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.