Is it possible to host multiple wp installations under one domain and have each installation as a sub folder using Nginx? I've try every possible combination with the configuration file and i keep being thrown at a 404 page. If there was a way to tell try_files to look inside of a folder for each url used, that would be cool.

location / {
        try_files $uri $uri/ /$some-folder/index.php?$args;
    }

is there any way to tell nginx that it should look in a folder for each url used? by url i mean something like this. having problems with the permalinks.

domain.com/wp-installation-1
domain.com/wp-installation-2
domain.com/wp-installation-3

I've checked other posts in stackoverflow and no one seems to have found a solution. Should i just go back to apache for this one? I'm surprised nginx doesn't have a solution for this.

Here is my configuration file

server {
    listen 80;
    server_name 104.131.123.171;
    return 301 http://www.sharkstaging.com;
}


server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;

    #this wont work so i've commented it out
    #location /wp {
    #    tryfiles $uri $uri/ /index.php?q=$uri&$args;
    #}

    #tried doing something like this but wont work, i'm sure its something wrong
    location /wp1 {
        tryfiles $uri $uri/ /wp/index.php?q=$uri&$args;
    }

    location /wp2 {
        tryfiles $uri $uri/ /wp/index.php?q=$uri&$args;
    }



    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
    #location /RequestDenied {
    #   proxy_pass http://127.0.0.1:8080;
    #}

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    #error_page 500 502 503 504 /50x.html;
    #location = /50x.html {
    #   root /usr/share/nginx/html;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    #   # With php5-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}



    location = /robots.txt { access_log off; log_not_found off; }
    location ~ /\. { deny  all; access_log off; log_not_found off; }
}
share|improve this question
    
If you install WordPress in those subfolders, there's no need to even modify your Nginx conf. It will work out of the box. – rnevius Feb 19 '15 at 8:07
    
it doesnt, i get 404 pages on a fresh installation of nginx on ubuntu (latest version) – Sarmen B. Feb 19 '15 at 8:09
    
i posted my config file and put some comments in it. – Sarmen B. Feb 19 '15 at 8:11

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.