• 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 http://www.example.com/wp-admin/network/ instead of http://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 - 31 through 45 (of 84 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    šŸ³ļøā€šŸŒˆ Advisor and Activist

    FastCGI shouldn’t matter. Nothing in that tells WP where it is.

    Only three things tell WP it’s address:

    1) Where it’s actually installed šŸ˜‰
    2) You (manually editing things, which we know you didn’t do)
    3) .htaccess/nginx

    Well… maybe 4 would be ‘httpd.conf settings’ btu that would have shown up earlier.

    Thread Starter hgrianevans

    (@hgrianevans)

    Hmmm…this has got me thinking…

    Since my non-wp site is served under http://www.domain and I created a non-www server section for nginx, I might as well go whole hog and create a specific document root for wp, thus allowing me to install WP in that root.

    e.g.

    server {
    listen 80;
    root /usr/local/nginx/htdocs;
    server_name www.domain.com;
    ...
    }
    server {
    listen 80;
    root /usr/local/nginx/WP-docs;
    server_name domain.com;
    ...
    }

    This might work…will let ya know.

    Looking at some of the nginx config examples, it seems it would be much easier if all of this was in the root, but as I’ve pointed out, my main non-wp site’s already there.

    @hgrianevans You have an interesting issue to solve (but, not hard to solve).

    location ^~ /blogs

    The conf is telling WP it’s really in the main folder. (The .htaccess for Multisite is different than single install, so I believe they’re different for nginx too)

    I was reading http://wiki.nginx.org/WordPress and it has a different explanation of how to do subfolders, and it has the multisite info, but I know every server’s a little different.

    Very true. From what I see from Mika’s answers, there is nothing wrong with your particular WordPress installation as a multisite on a sub-directory. The nginx configuration for a single site and multisite are quite different. If you (@hgrianevans) followed the nginx configuration for a multisite from http://wiki.nginx.org/WordPress or from http://wiki.nginx.org/WordPress , everything should work as expected (or at least, you can make them work, if you tweak a little for your specific situation; multisite on a sub-directory).

    Since my non-wp site is served under http://www.domain and I created a non-www server section for nginx, I might as well go whole hog and create a specific document root for wp, thus allowing me to install WP in that root.

    A good idea indeed. But, if your nginx configuration is flawed, then you’d still have some issues accessing the dashboard for the sites created under multisite.

    Thread Starter hgrianevans

    (@hgrianevans)

    Hi Pothi,

    What’s confusing me…I understand how nginx can rewrite an URL to handle it internally, but I’m not understanding how nginx could make WP display an incorrect URL in WP’s menus.

    Hello hgrianevans,

    I’m not understanding how nginx could make WP display an incorrect URL in WP’s menus.

    It’s strange indeed.

    BTW, I just tested what you were trying to achieve. Here is what I got without any issues…

    elegantblogs . net (a standalone installation based on the latest version of WP)
    above URL + /blogs/ (a multisite installation based on trunk version; you can see 2012 theme)
    /blogs/blog1/ (a site under multisite)
    /blogs/blog2/ (another site under multisite)

    Update: The above URL may go off after a few days (as it is only my test domain). It runs on Nginx, but my “Server” header is overwritten by CloudFlare. I have my own nginx configuration for multisite. You can check it out at https://github.com/pothi/WordPress-Nginx/blob/master/sites-enabled/mu-dir-domainname.com.conf (please remove the two spaces around the dot to get the URL).

    Thread Starter hgrianevans

    (@hgrianevans)

    do the network admin urls in wp-admin point to the correct URL? That’s the issue I was seeing.

    Yes, they do.

    Thread Starter hgrianevans

    (@hgrianevans)

    I’ll give it a try in a few hours.

    Thread Starter hgrianevans

    (@hgrianevans)

    Pothi,

    Quick question: how would you change your config to redirect any urls not /blogs or below back to the http://www.domain.com server block?

    Thanks.

    @hgrianevans

    You can try – http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-in-subdirectory-itself/

    It is already tested and working config.

    You just need to make 2 changes in it – domain name & folder name.

    Quick question: how would you change your config to redirect any urls not /blogs or below back to the http://www.domain.com server block?

    In my config – if a file exist in root dir, it will be used first. So I guess you will not face that issue!

    Thread Starter hgrianevans

    (@hgrianevans)

    @rahul286

    I’ll take a look at your config too.

    Just to be clear on my question…my non-wordpress php driven site is currently running on a http://www.domain.com nginx server block.

    Because WP prefers we drop the ‘www’ I’m testing with a non-www server block for just the WP URLs. Just in case someby takes a non-WP url from my site:

    http://www.domain.com/somedir/somefile and tries dropping the ‘www’ I want to make sure that the wordpress server block redirects non-WP requests back to http://www.domain.com. Is there an efficient way for nginx to do this?

    Thread Starter hgrianevans

    (@hgrianevans)

    @rahul286

    …and we’re back to square one. Followed your exact directions in http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-in-subdirectory-itself/

    Did a fresh install of WP database and folder. Installed WP, installed network and sadly the Network Admin URLs on the dashboard still point to wp-admin in root even though it’s in /blogs.

    I’m officially in WordPress/Nginx hell. Will try Pothi’s setup later but right now I need to get as far away from my keyboard as possible. šŸ™‚

    Pothi,

    Quick question: how would you change your config to redirect any urls not /blogs or below back to the http://www.domain.com server block?

    Thanks.

    By adding a location / { try_files $uri /index.php; } block as you can see in my updated Github configuration entry at https://github.com/pothi/WordPress-Nginx/blob/master/sites-enabled/mu-dir-dir-domainname.com.conf .

    Update:

    Basically, you would have at least two location blocks…

    – One for WordPress that looks like location /blogs { }
    – One for the non-WordPress site at the root, like location / { }

    I hope this helps.

    Thread Starter hgrianevans

    (@hgrianevans)

    Pothi,

    Going to try your config in a few minutes after a very late dinner.

    Looking at the location / though the use case should be:

    http://www.domainname.com has a non-WordPress installation at its root (note the www) so I need to redirect to www anything that’s not php.

    Thanks!

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