Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

[I just posted this on the WP Forums, too, before anyone starts Googling and saying that this is posted somewhere else]

I'm hoping this isn't a duplicate, but I've been searching here and Googling and I haven't been able to find anything.

I'm currently running a web server that constitutes nginx as both a front-end proxy to a LAMP stack and the web server for static sites. I'm working on some development for a site that will be powered by WP.

Currently, mysite.com is served up by nginx as a static site. The WP install will be served out of a subfolder, mysite.com/sub. The document root for the nginx server (the static files) and the document root for the Apache server (all dynamic content, and also where the WP files are currently installed) are NOT the same directory. I want to install WP in mysite.com/sub so that only this subdirectory is powered by WP while completely ignoring the root of my site but all of the articles I have read discuss using WP to power the root while simply installing the files elsewhere.

It took me forever to write all the correct proxy passing rules in my nginx configuration just to make the installation happen properly, and that is all good and well, but WordPress is operating out of mysite.com instead of mysite.com/sub and I'm not 100% sure what the easiest way to fix this is, since mysite.com isn't powered by Apache and so there are no PHP or .htaccess files to tinker with in the root of that directory.

I realize that this is sort of rambling and difficult to explain, I'll be happy to provide answer to any questions for anyone that thinks they can point me down the right path.

I would prefer to use this structure instead of using a subdomain, so if anyone out there has any suggestions I'd really appreciate it.

share|improve this question
add comment

3 Answers 3

If you are still looking for a solution, your nginx configuration should look like this in order to achieve what you described...

server {
  listen 80;
  server_name yourdomain.com

  root /path/to/yourdomain.com;
  index index.php index.html;

  location / {
    # directives to handle static site
  }

  location /sub {
    # directives to handle WordPress
    try_files $uri $uri/ /sub/index.php?$args;
  }

  location ~* \.php$ {
    # pass to Apache backend
  }
}
share|improve this answer
add comment

WordPress needs no special configuration to install in a subdirectory. Simply install it in mysite.com/sub, and run mysite.com/sub/install.php. WordPress will know its location, and will use mysite.com/sub as its URL.

share|improve this answer
    
That's good and well, except that isn't the case, and I believe it has to do with the fact that I'm using apache ghosts with an nginx front end. I installed wordpress in the sub directory and ran the installer, but the site still insists on using URL's such as "mysite/wp-admin" instead of "mysite/sub/wp-admin". The Settings panel also shows that the Site URL and Wordpress URL are both mysite.com. –  Doug Stephen Aug 15 '11 at 17:01
    
...and all of that nginx/apache configuration bit is out of scope/too localized for WPSE. –  Chip Bennett Aug 15 '11 at 18:07
    
Fair enough. I'll fish it around on Server Fault then. Thanks! –  Doug Stephen Aug 15 '11 at 19:08
add comment

Doug, in your wp-config, set the WP_HOME, and WP_SITEURL to have /blog/ after the site name and you'll be good.

share|improve this answer
    
I had tried that and it hadn't helped. The issue was with server configuration and had to do with the way the proxy passing mapped to physical directories on the box since the root directory for the nginx location wasn't equivalent to the root directory for the dynamic files being processed by Apache. The configuration scripts were just putting files in the wrong places. It's no longer an issue and it was just an edge-case for a weird development environment I was forced in to working on. –  Doug Stephen Nov 23 '11 at 20:08
    
ahh ok. cool :) –  Vid Luther Nov 23 '11 at 20:56
add comment

Your Answer

 
discard

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

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