0

I am trying to set up 2 wordpress servers with Nginx.

Both sites are up and running fine:

https://server.io/learn

https://server.io/event

However, I cannot access the page I created:

https://server.io/learn/2016/06/we-can-get-you-hired/

For /learn or /event, nginx can access the right content folder.

/srv/server.wordpress/event/index.php > GET /event/ HTTP/1.1
/srv/server.wordpress/learn/index.php > GET /learn/ HTTP/1.1

But for https://server.io/learn/2016/06/we-can-get-you-hired/, it is wrong.

/srv/server.wordpress/index.php > GET /learn/2016/06/we-can-get-you-hired/ HTTP/1.1
                    ^
                    It doesn't go to the subfolder /learn.

The error log:

FastCGI sent in stderr: "Primary script unknown" while reading response header 
from upstream,  request: "GET /learn/2016/06/we-can-get-you-hired/ HTTP/1.1", 
upstream: "fastcgi://127.0.0.1:9000", host: "server.io", referrer: 
"https://server.io/learn/"

Here are my configuration files:

File: /etc/nginx/sites-enabled/server

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name server.io *.server.io;
    return 301 https://server.io$request_uri;
}
server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    server_name server.io *.server.io;
    location /learn {
        root /srv/server.wordpress;
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location /event {
        root /srv/server.wordpress;
        index index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        root /srv/server.wordpress;
        include fastcgi_shared.conf;
    }
}

File: /etc/nginx/fastcgi_shared.conf

fastcgi_cache  microcache;
fastcgi_cache_key $scheme$host$request_method$request_uri;
fastcgi_cache_valid 200 304 10m;
fastcgi_cache_use_stale updating;
fastcgi_max_temp_file_size 1M;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
include        fastcgi_params;
0

You want to enable WordPress multisite and put this in your ngix configuration

if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) /wp$1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ /wp$1 last;
}
  • It doesn't work. Now, all of them lost the subfolder. /srv/server.wordpress/index.php > GET /learn/ HTTP/1.1 /srv/server.wordpress/index.php > GET /event/ HTTP/1.1 /srv/server.wordpress/index.php > GET /learn/2016/06/we-can-get-you-hired/ HTTP/1.1 – angelokh Jun 30 '16 at 22:10
  • Do you mind if we move this to chat and then I will update the answer? chat.stackexchange.com/rooms/41881/… – user5870571 Jun 30 '16 at 22:19
  • Yes, I have joined. – angelokh Jun 30 '16 at 22:39
  • Can you join again and add me in the room? I can't type. – angelokh Jun 30 '16 at 23:16
  • I tried multiple times and it won't add your username. – user5870571 Jun 30 '16 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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