# Domain.com/phpmyadmin/index.php how-to?

**URL:** <https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387>\
**Category:** NGINX\
**Created:** [April 5, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387 "2011-04-05T17:52:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 5, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387/1 "2011-04-05T17:52:30Z")

</div>

Hallo Everybody,

I have a working default config,  
catching /index.html and /index.php fine  
(incl. passing php request to an upstream backend runing php-fpm)

now i want the server to serve requests to  
‘[anydomain.com/phpmyadmin/index.php](http://anydomain.com/phpmyadmin/index.php)’  
or even just ‘[anydomain.com/phpmyadmin/](http://anydomain.com/phpmyadmin/)’  
from /usr/share/phpmyadmin

for static content this should be easy with something like this:

location /phpmyadmin/ {  
alias /usr/share/phpmyadmin/;  
}

and for php?  
i tried with a regular expression:

location ~ ^/phpmyadmin/(._)(.php)$ {  
 #fastcgi\_split\_path\_info ^(.+.php)(._)$;  
fastcgi\_pass php\_fpm\_backend;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME  
/usr/share/phpmyadmin/$fastcgi\_script\_name;  
include fastcgi\_params;  
…  
}

without success…  
it seems as if the static location block catches all and presents the  
raw php source to me now…  
while i thought that my regex which should match requests to  
[domain.com/phpmyadmin/index.php](http://domain.com/phpmyadmin/index.php) exactly

what would be the best practice to serve stuff like this? alias?  
rewrites? regex? try files?

thanks a lot for any help!  
mart

Posted at Nginx Forum:

> **[domain.com/phpmyadmin/index.php how-to?](https://forum.nginx.org/read.php?2,188514,188514#msg-188514)**
>
> Hallo Everybody, I have a working default config, catching /index.html and /index.php fine (incl. passing php request to an upstream backend runing php-fpm) now i want the server to serve requests to 'anydomain.com/phpmyadmin/index.php' or even just

---

<div class="post-metadata">

**Author:** ![kalinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kalinski](https://www.ruby-forum.com/u/kalinski)\
**Post date:** [April 5, 2011, 8:04pm UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387/2 "2011-04-05T20:04:45Z")

</div>

something like this?

```
    location ~ \.(php)$ {
            fastcgi_pass php_fpm_backend;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME

```

/usr/share/phpmyadmin/$fastcgi\_script\_name;  
…  
}

this catches all files with .php extension.

Posted at Nginx Forum:

> **[Re: domain.com/phpmyadmin/index.php how-to?](https://forum.nginx.org/read.php?2,188514,188556#msg-188556)**
>
> Hallo Everybody, I have a working default config, catching /index.html and /index.php fine (incl. passing php request to an upstream backend runing php-fpm) now i want the server to serve requests to 'anydomain.com/phpmyadmin/index.php' or even just

---

<div class="post-metadata">

**Author:** ![kalinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kalinski](https://www.ruby-forum.com/u/kalinski)\
**Post date:** [April 5, 2011, 9:02pm UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387/3 "2011-04-05T21:02:12Z")

</div>

Hi Paxxil,

thanks for your swift reply, actually that’s not exactly what I meant:

there is two directories for dynamic content (php):

default:

/var/www/nginx\_default/ or similar

which will usually work for your code above (catching all urls ending  
with .php)  
with the SCRIPT\_FILENAME path set to the right dir

but then there is another one:

/usr/share/phpmyadmin/

that i want to make available to everybody (on the same domain)  
under the url: [anydomain.com/phpmyadmin/](http://anydomain.com/phpmyadmin/)

these will also match .php$ but should get directed to the phpmyadmin  
directory  
I used this regex:  
location ~ ^/phpmyadmin/(.\*)(.php)$  
to catch it but it won’t work like expected…

i am now doing a workaround with a subdomain: [phpmyadmin.anydomain.com](http://phpmyadmin.anydomain.com)  
which can be cought in the server block by the domain name  
so i can set root directory to /usr/share/phpmyadmin

but i am still not satisfied with this as it involves changing the NS  
entries  
while a “subfolder” will be much easier to setup

any help very much appreciated (not to say needed, hehe)

greetz  
mart

Posted at Nginx Forum:

> **[Re: domain.com/phpmyadmin/index.php how-to?](https://forum.nginx.org/read.php?2,188514,188577#msg-188577)**
>
> Hallo Everybody, I have a working default config, catching /index.html and /index.php fine (incl. passing php request to an upstream backend runing php-fpm) now i want the server to serve requests to 'anydomain.com/phpmyadmin/index.php' or even just

---

<div class="post-metadata">

**Author:** ![kalinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kalinski](https://www.ruby-forum.com/u/kalinski)\
**Post date:** [April 6, 2011, 11:03am UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387/4 "2011-04-06T11:03:25Z")

</div>

yes thank you! i guess i just forgot to put the root directive…

or better for my case to set the alias:

location ~ ^/phpmyadmin/(.\*)(.php)$ {

alias /usr/share/phpmyadmin/;

fastcgi\_pass upstream\_backend;

etc…

}

Posted at Nginx Forum:

> **[Re: domain.com/phpmyadmin/index.php how-to?](https://forum.nginx.org/read.php?2,188514,188695#msg-188695)**
>
> Hallo Everybody, I have a working default config, catching /index.html and /index.php fine (incl. passing php request to an upstream backend runing php-fpm) now i want the server to serve requests to 'anydomain.com/phpmyadmin/index.php' or even just

---

<div class="post-metadata">

**Author:** ![kalinski](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kalinski](https://www.ruby-forum.com/u/kalinski)\
**Post date:** [April 5, 2011, 10:17pm UTC](https://www.ruby-forum.com/t/domain-com-phpmyadmin-index-php-how-to/205387/5 "2011-04-05T22:17:45Z")

</div>

On Tue, Apr 05, 2011 at 03:01:21PM -0400, kalinski wrote:

Hi there,

it seems to work fine for me. Perhaps there is something extra in your  
configuration?

When I use two blocks:

include fastcgi.conf;  
location ~ ^/a/.\*php$ {  
root /tmp;  
fastcgi\_pass unix:php.sock;  
}  
location ~ .php$ {  
fastcgi\_pass unix:php.sock;  
}

then getting /t/env.php shows the output of the file  
/usr/local/nginx/html/t/env.php; while getting /a/env.php shows the  
output of the file /tmp/a/env.php.

Exactly as I’d expect.

> I used this regex:  
> location ~ ^/phpmyadmin/(.\*)(.php)$  
> to catch it but it won’t work like expected…

As above, it works for me.

For each request, exactly one location is used. What does “grep location  
nginx.conf” show? It will hopefully show the various location blocks you  
define, in order.

That, plus the http request you make, should let you determine which  
location block is being used. (Or you could just look in the debug log.)

If it’s not what you want, then you can configure things differently.

Good luck with it,

## f

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