• Using nginx, I’ve installed WordPress to /blogs and enabled network sites.

    All my main site links point to example.com/blogs, but when I go to network admin the links point to https://www.example.com/wp-admin/network/ instead of https://www.example.com/blogs/wp-admin/network/

    Here’s the multisite section in my config:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    $base = '/blogs';
    define('DOMAIN_CURRENT_SITE', 'www.example.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    If I tried changing PATH_CURRENT_SITE to /blogs, I’d get a db connection error.

    Thanks.

Viewing 15 replies - 61 through 75 (of 84 total)
  • IMO, it is even easier to maintain, if hgrianevans installs WordPress with ‘www’. ??

    Agree. ??
    Life is easy when you use either WWW or non-WWW everywhere. We prefer not to use WWW (sticking with WordPress side) ??

    Thread Starter hgrianevans

    (@hgrianevans)

    Took a few minutes to depersonalize the server block but here’s the config of my non-wp site:

    server {
    listen 80;
    root /usr/local/nginx/htdocs;
    server_name www.example.com;
    include /usr/local/nginx/conf/fastcgi-php.conf;
    #shtml files are actually php files
    index index.shtml index.php index.html;
    fastcgi_intercept_errors  on;
    error_page 404 /dhe404.shtml;
    error_page 403 /dhe403.shtml;
    charset ISO-8859-1;
    #gzip stuff deleted
    
    if (-f $document_root/maintenance.html) {
    return 503;
    }
    error_page 503 @503;
    location @503 {
    rewrite ^(.*)$ /maintenance.html break;
    }
    
    location / {
    index index.shtml index.php;
    }
    
    location ~ \.(shtml|php|inc)$ {
    fastcgi_pass 127.0.0.1:10004;
    }
    
    # start of extensionless stuff
    location ~ ^/(various|extensionless|files)(/.*$|$) {
    rewrite ^/(various|extensionless|files)(/.*$|$) /$1.php?mypath=$2 last;
    }
    
    location ~ ^/(news|somearea)(/.*$|$)  {
    if ($http_user_agent !~ FeedBurner) {
    rewrite ^/news/main/main.xml$ https://feeds.feedburner.com/exampleNews last;
    }
    if ($http_user_agent !~ FeedBurner) {
    rewrite ^/somearea/archives/somearea.xml$ https://feeds.feedburner.com/examplessomearea last;
    }
    rewrite ^/(news|somearea)(/.*$|$) /$1.php?mypath=$2 last;
    }
    
    location ~ /(various|extensionless|files|in|subdirs)(/|$) {
    if ($uri ~ ^(.*/(various|extensionless|files|in|subdirs))($|/.*)) {
    rewrite ^(.*/(various|extensionless|files|in|subdirs))($|/.*) $1.php?mypath=$3 last;
    }
    }
    
    #start of new galleries check
    location ~ ^/galleries(/.*$|$) {
    if (-f /usr/local/nginx/htdocs/pixcache$request_uri/index.html) {
    expires 2h;
    rewrite ^(.*)$ /pixcache$1/index.html last;
    break;
    }
    rewrite ^/galleries(/.*$|$) /galleries.php?mypath=$1 last;
    }
    #end of new galleries check
    # end of extensionless stuff
    
    location ~* ^.+\.(jpg|jpeg|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mov)$ {
    error_page 403 /dhe403.shtml;
    expires 30d;
    valid_referers none blocked *.example.com example.com ;
    if ($invalid_referer) {
    return  403;
    }
    }
    
    location ~* ^.+\.html$ {
    expires 2h;
    }
    
    location ~* ^.+\.(gif|js)$ {
    expires 30d;
    }
    }
    Thread Starter hgrianevans

    (@hgrianevans)

    Pothi and Rahul286,

    Skipping the www vs. non-www debate for a second…and yes I’m researching right now how Google deals with the change…do either of you have any inkling as to my big question of why WP keeps thinking some of it’s URLs are in root when it’s installed in a subdirectory? That’s the thing that had Mika and I banging our heads.

    do either of you have any inkling as to my big question of why WP keeps thinking some of it’s URLs are in root when it’s installed in a subdirectory? That’s the thing that had Mika and I banging our heads.

    That’s why I joined in the conversation in this thread, even though I have been keeping an eye to this thread since its beginning. ??

    My guess was (and still is) that the issue you see is due to Nginx and there is nothing with the installation of WP or how it thinks about its URLs. Please visit https://web-sniffer.net/ and type yourdomain.com/sub-directory/wp-login.php and let us know what HTTP status code, you get. If you get 200, then both Nginx and WP are working correctly. If you get 301 or 404, then it is time to dig through the error-logs of your Nginx. Whether you use Windows or Linux server, check your access and error logs continuously (in Linux, it could be done with tail -f /path/to/nginx/access.log), when you type different URLs (such as yourdomain.com/sub-directory/wp-login.php, yourdomain.com/sub-directory/, https://www.yourdomain.com/sub-directory, etc). That should give more ideas to figure out the issue.

    Thread Starter hgrianevans

    (@hgrianevans)

    There’s no problem with domain.com/blogs/wp-login.php It returns a 200.

    What I’m talking about is that the menu item My Sites>Network Admin>(Dashboard|Sites|Users|Visit Networks) is pointing to /wp-admin, etc instead of /blogs/wp-admin and the wp-site table is point to / instead of /blogs

    That’s the main problem I’m facing. Nginx isn’t creating the URL’s that WP is displaying in its menus and Nginx isn’t putting the wrong directory in wp-sites. Why is the wrong info being inserted into WP’s database?

    In other words I’m able to serve the site up, I just can’t administer it.

    My guess is that it could be due the incorrect Nginx configuration at the time of installation of multisite.

    Thread Starter hgrianevans

    (@hgrianevans)

    Well I used rahul286’s config…which works for him… and reinstalled WP from scratch. Same problem.

    It’s 639am so I’m heading off to bed finally (very tired). I’ll nuke the WP database and files tomorrow and try your config.

    I understand what you’ve been going through. Please be advised that you still need to make changes in my configuration to make it work for your use case. For example, as you may already aware of, I use fastcgi_pass fpm; that you have to modify it as fastcgi_pass 127.0.0.1:10004; to make the entire configuration to work for your particular server. Also, please just removelocation / { try_files $uri $uri/ /index.php; } line in my “globals/common-locations.conf” file and insert the following to redirect every non-WP to ‘www’ version of the site (aka non-WP site)…

    location / {
      return 301 $scheme://www.domainname.com$request_uri;
    }

    As you are probably using a separate server for ‘www’ version of the site, please remove the first server block of my configuration that does 301 redirect irrespective of what the content is based upon.

    @hgrianevans
    There are many things I see quite non-standard in your config.

    Its hard to find out problem without debugging. A quick advise would we to move if{..} block outside location{..} block… (whenever possible)
    Reason – https://agentzh.blogspot.in/2011/03/how-nginx-location-if-works.html

    If you need some help in debugging your live-site, please try – https://rtcamp.com/tutorials/debugging-nginx-configuration/

    Thread Starter hgrianevans

    (@hgrianevans)

    @rahul286,

    There are many things I see quite non-standard in your config.

    Well, anything that looks non-standard has been the result of lengthy forum threads involving Nginx’s author Igor, so if he’s cool with it, I’m cool with it. ?? The stuff’s been working for years.

    @pothi, yes I changed the fpm lines. As I’ve said to both of you, serving the WordPress is no problem. It’s that wordpress is putting / in some of it’s menus and databases instead of /blogs.

    Thread Starter hgrianevans

    (@hgrianevans)

    Just one other quick note: last night when I tried a clean install with Rahul286’s config, the only thing in the domain.com server block was Rahul’s config, nothing else. It never touched the https://www.domain server block at all.

    Which WP file handles the network/multisite end of the install process? Maybe we could see where WP is grabbing the variable from that’s messing up /blogs to / in the database?

    @pothi, yes I changed the fpm lines.

    If you already tried my configuration during the installation process of WP multisite, and if you still see the issue, then I’m unsure how to troubleshoot further. I’m sorry.

    My configuration works fine for me and I’ve provided you a live (example) site that is still live as of this writing. If I could not administer my live example site, I could not have created the sites or could not have changed the themes in those sites.

    Which WP file handles the network/multisite end of the install process? Maybe we could see where WP is grabbing the variable from that’s messing up /blogs to / in the database?

    I’m more into server admin, than into WordPress core. So, I don’t know the answer to the above question. Sorry, again.

    I’m still curious on what went wrong for your specific situation. So, I’m not unsubscribing from this thread. But, you may not get my further replies as I do not know how to troubleshoot further. ?? Please feel free to mention me, if you need my attention or assistance.

    Thread Starter hgrianevans

    (@hgrianevans)

    @pothi,

    Thanks for your all your help.

    I just nuked the WordPress database and directory and the only thing in the domain.com server block was your config.

    Again, WP installed fine in /blogs. Again, I was able to go to WP in /blogs. Did the network install and, sadly, once again this is what WP gave:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', 'domain.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    This is nuts. I’m going to try hard-coding the abspath value. If that fails, I just might do multiple installs. ??

    Well, anything that looks non-standard has been the result of lengthy forum threads involving Nginx’s author Igor, so if he’s cool with it, I’m cool with it. ?? The stuff’s been working for years.

    Just because something works doesn’t make it standard.

    Your config uses a lot of if directives, rather than better and more efficient try_file

    Sections like following have unnecessary stuff!:

    location ~ /(various|extensionless|files|in|subdirs)(/|$) {
    if ($uri ~ ^(.*/(various|extensionless|files|in|subdirs))($|/.*)) {
    rewrite ^(.*/(various|extensionless|files|in|subdirs))($|/.*) $1.php?mypath=$3 last;
    }
    }

    You can write one line only (something like below) and it can do job of above 3 lines:

    rewrite ^(.*/(various|extensionless|files|in|subdirs))($|/.*) $1.php?mypath=$3 last;

    You can have rewrite like above directly in server {..} block. See – https://wiki.nginx.org/HttpRewriteModule#rewrite

    Debugging is easy when you remove unwanted lines from your config…

    And for this $base = '/';… try manually fixing it to:

    $base = '/blogs/';
    define('PATH_CURRENT_SITE', '/blogs/');

    Thread Starter hgrianevans

    (@hgrianevans)

    I’m gonna have another go with your config on Saturday.

Viewing 15 replies - 61 through 75 (of 84 total)
  • The topic ‘nginx – Network admin pointing to root as opposed to subdirectory’ is closed to new replies.