Nginx config to serve multiple Wordpress from subdirectories


#1

Hey guys, I want to install WP like this – mysite.com/member/WPinstall1 mysite.com/member/WPinstall2 mysite.com/member/WPinstall3 and so on..

Here is my current configuration, could you please help me with the correct config?

server {  
        server_name mysite.com http://www.mysite.com;  

    access_log   /var/log/nginx/mysite.com.access.log;  
    error_log    /var/log/nginx/mysite.com.error.log;  

    root /var/www/mysite.com/htdocs;  
    index index.php;  

    set $dir "";  

    if ($request_uri ~ ^/([^/]*)/.*$ ) {  
          set $dir1 /$1;  
    }  

    location / {  
            try_files $uri $uri/ $dir1/index.php?$args;  
    }  

    location ~ \.php$ {  
           include fastcgi_params;  
            fastcgi_pass unix:/var/run/php5-fpm.sock;  
    }  

}

This config is giving me file not found errors on page/post links on both mysite.com and mystie.com/member/WPinstall1 etc.

Thanks for any help.


#2

Try following changes…

 if ($request_uri ~ ^/member/([^/]*)/.*$ ) {  
          set $dir1 /$1;  
    }  

    location /member/ {  
            try_files /member$uri /member$uri/ /member/$dir1/index.php?$args;  
    }

#3