# Non-root install of Wordpress in an already running nginx site

**URL:** <https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752>\
**Category:** NGINX\
**Created:** [April 11, 2012, 1:53am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752 "2012-04-11T01:53:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 11, 2012, 1:53am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/1 "2012-04-11T01:53:43Z")

</div>

Been running nginx on our server for years. php-fpm, multiple location  
sections, etc., all working fine.

However, for one project we’re launching my partner wants to run a  
wordpress blog from a subdirecory, i.e., [example.com/ournewblog](http://example.com/ournewblog)

Can anyone point me to an example of a location block for the wordpress  
blog that handles all the wordpress needs while not futzing with all the  
other locations or causing php problems elsewhere?

Thanks!

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 11, 2012, 2:04am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/2 "2012-04-11T02:04:11Z")

</div>

2012/4/11 Ian M. Evans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Been running nginx on our server for years. php-fpm, multiple location  
> sections, etc., all working fine.
> 
> However, for one project we’re launching my partner wants to run a  
> wordpress blog from a subdirecory, i.e., [example.com/ournewblog](http://example.com/ournewblog)
> 
> Can anyone point me to an example of a location block for the wordpress  
> blog that handles all the wordpress needs while not futzing with all the  
> other locations or causing php problems elsewhere?

location /ournewblog/ {  
root …;  
try\_files $uri /ournewblog/index.php?q=$uri;  
location ~ .php$ {  
fastcgi\_pass …  
…  
}  
}

Hopefully you don’t have regex based location on server { } block.  
Otherwise you can try location ~ ^/ournewblog/ instead.

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 11, 2012, 2:23am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/3 "2012-04-11T02:23:24Z")

</div>

On Tue, April 10, 2012 8:02 pm, Edho A. wrote:

> Otherwise you can try location ~ ^/ournewblog/ instead.  
> I’ve always been a bit unsure of handling nginx locations so how can I  
> tell if I have a “regex based location”?

Most of my locations are like:

location / {  
index index.shtml index.php;  
}  
location ~ .(shtml|php|inc)$ {  
fastcgi\_pass 127.0.0.1:10004;  
}

# start of extensionless stuff

location ~ ^/(bunch|of|site|sections)(/.\*$|$) {  
…  
}  
location ~ /(more|extensionless|sections)(/|$) {  
…  
}

Thanks.

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 11, 2012, 3:48am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/4 "2012-04-11T03:48:35Z")

</div>

On 04/10/2012 05:22 PM, Ian M. Evans wrote:

> > Hopefully you don’t have regex based location on server { } block.  
> > Otherwise you can try location ~ ^/ournewblog/ instead.  
> > I’ve always been a bit unsure of handling nginx locations so how can I  
> > tell if I have a “regex based location”?

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 12, 2012, 2:17pm UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/5 "2012-04-12T14:17:53Z")

</div>

On 10/04/2012 8:26 PM, Edho A. wrote:

> this is regex based location block. It gets higher priority when  
> accessing /ournewblog/index.php .
> 
> You need location ~ ^/ournewblog/ instead and put it as the first  
> location block (before other locations).

Thanks…I’ll give it a try.

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 11, 2012, 2:27am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/6 "2012-04-11T02:27:43Z")

</div>

2012/4/11 Ian M. Evans [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > Hopefully you don’t have regex based location on server { } block.  
> > location ~ .(shtml|php|inc)$ {  
> > fastcgi\_pass 127.0.0.1:10004;  
> > }

this is regex based location block. It gets higher priority when  
accessing /ournewblog/index.php .

You need location ~ ^/ournewblog/ instead and put it as the first  
location block (before other locations).

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 12, 2012, 2:21pm UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/7 "2012-04-12T14:21:37Z")

</div>

2012/4/12 Ian E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

Sorry, seems like location ^~ /ournewblog/ will also do the job.

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 13, 2012, 4:14am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/8 "2012-04-13T04:14:59Z")

</div>

On Thu, April 12, 2012 8:20 am, Edho A. wrote:

> Sorry, seems like location ^~ /ournewblog/ will also do the job.

Hmm…already encountered one issue:

location ^~ /ournewblog/ {  
try\_files $uri /ournewblog/index.php?q=$uri;  
location ~ .php$ {  
fastcgi\_pass 127.0.0.1:10004;  
}  
}

Just started the install and it duplicates the admin subdirectory links  
so  
we get:

[http://www.example.com/ournewblog/wp-admin/wp-admin/setup-config.php](http://www.example.com/ournewblog/wp-admin/wp-admin/setup-config.php)

Any ideas?

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 13, 2012, 5:39am UTC](https://www.ruby-forum.com/t/non-root-install-of-wordpress-in-an-already-running-nginx-site/218752/9 "2012-04-13T05:39:28Z")

</div>

Am 13.04.2012 09:14 schrieb “Ian M. Evans” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> On Thu, April 12, 2012 8:20 am, Edho A. wrote:
> 
> > Sorry, seems like location ^~ /ournewblog/ will also do the job.
> 
> Hmm…already encountered one issue:

Try

> location ^~ /ournewblog/ {

try\_files $uri $uri/ /ournewblog/index.php?q=$uri;
