# Single server with multiple hierarchies

**URL:** <https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833>\
**Category:** NGINX\
**Created:** [August 1, 2012, 1:37pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833 "2012-08-01T13:37:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 1, 2012, 1:37pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/1 "2012-08-01T13:37:41Z")

</div>

Hi,

My directory structure is:  
/usr/share/nginx/www  
/magento/current ← This is my application  
/phpmyadmin

I changed the root of the server to  
/usr/share/nginx/www/magento/current.

Now my app works perfectly when I access [http://myserver/index.php](http://myserver/index.php).

I would like to configured phpmyadmin such that it is accessible as  
[http://myserver/phpmyadmin/index.php](http://myserver/phpmyadmin/index.php).

Please note that the root of my application is different than the root  
of phpmyadmin and both are to be served from the same server.

If I create a location with ^~ /phpmyadmin/ can I set a root in it? Will  
I have to do something to pass the index.php to FCGI. Will this have to  
be done in the location directive?

Thanks,  
Yash

Posted at Nginx Forum:

> **[Single server with multiple hierarchies](https://forum.nginx.org/read.php?2,229189,229189#msg-229189)**
>
> Hi, My directory structure is: /usr/share/nginx/www /magento/current \<- This is my application /phpmyadmin I changed the root of the server to /usr/share/nginx/www/magento/current. Now my app works perfectly when I access http://

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 1, 2012, 9:08pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/2 "2012-08-01T21:08:49Z")

</div>

On Wed, Aug 01, 2012 at 07:37:10AM -0400, yashgt wrote:

Hi there,

> My directory structure is:  
> /usr/share/nginx/www  
> /magento/current ← This is my application  
> /phpmyadmin
> 
> I changed the root of the server to  
> /usr/share/nginx/www/magento/current.

You changed the server{}-level “root” directive, so that any location{}  
that does not include its own “root” directive will use that one.

> I would like to configured phpmyadmin such that it is accessible as  
> [http://myserver/phpmyadmin/index.php](http://myserver/phpmyadmin/index.php).
> 
> Please note that the root of my application is different than the root  
> of phpmyadmin and both are to be served from the same server.

A http request comes in, and is processed by exactly one location. An  
internal rewrite may cause it to then be processed by one other  
location. This can happen again.

> If I create a location with ^~ /phpmyadmin/ can I set a root in it? Will  
> I have to do something to pass the index.php to FCGI. Will this have to  
> be done in the location directive?

Yes to each. You’ll probably want to nest locations, like

location ^~ /phpmyadmin/ {  
#root and other directives  
location ~ php {  
#php-relevant directives  
}  
}

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 6, 2012, 1:54pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/3 "2012-08-06T13:54:58Z")

</div>

Bang on target. Nested locations worked perfectly.

Posted at Nginx Forum:

> **[Re: Single server with multiple hierarchies](https://forum.nginx.org/read.php?2,229189,229326#msg-229326)**
>
> Hi, My directory structure is: /usr/share/nginx/www /magento/current \<- This is my application /phpmyadmin I changed the root of the server to /usr/share/nginx/www/magento/current. Now my app works perfectly when I access http://

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 15, 2012, 5:35pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/4 "2012-08-15T17:35:51Z")

</div>

Hi yashgt,

I’m having a similar issue trying to get Magento and WordPress running  
on a  
single IP. On Apache this is easy using vhost. I’ve never used nginx  
before,  
so don’t know it all that well. I’ve read and done lots of googling and  
your  
post seems to be the closest to what I’m trying to archive. Would it be  
possible for you to post a copy of you config\>

Cheers,

Martin

Posted at Nginx Forum:

> **[Re: Single server with multiple hierarchies](https://forum.nginx.org/read.php?2,229189,229726#msg-229726)**
>
> Hi, My directory structure is: /usr/share/nginx/www /magento/current \<- This is my application /phpmyadmin I changed the root of the server to /usr/share/nginx/www/magento/current. Now my app works perfectly when I access http://

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 15, 2012, 5:51pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/5 "2012-08-15T17:51:38Z")

</div>

On Wed, Aug 15, 2012 at 10:35 PM, martinlove [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi yashgt,
> 
> I’m having a similar issue trying to get Magento and WordPress running on a  
> single IP. On Apache this is easy using vhost. I’ve never used nginx before,  
> so don’t know it all that well. I’ve read and done lots of googling and your  
> post seems to be the closest to what I’m trying to archive. Would it be

That’d be different problem. Check this docs:

> **[Server names](http://nginx.org/en/docs/http/server_names.html)**

---

<div class="post-metadata">

**Author:** ![yashgt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/bcef8e/32.png) [@yashgt](https://www.ruby-forum.com/u/yashgt)\
**Post date:** [August 15, 2012, 10:38pm UTC](https://www.ruby-forum.com/t/single-server-with-multiple-hierarchies/221833/6 "2012-08-15T22:38:01Z")

</div>

Hi Yash,

Thanks for your prompt response. I’ll have a look at the docs.

Cheers,

Martin

Posted at Nginx Forum:

> **[Re: Single server with multiple hierarchies](https://forum.nginx.org/read.php?2,229189,229736#msg-229736)**
>
> Hi, My directory structure is: /usr/share/nginx/www /magento/current \<- This is my application /phpmyadmin I changed the root of the server to /usr/share/nginx/www/magento/current. Now my app works perfectly when I access http://
