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

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 ‘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 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:
http://forum.nginx.org/read.php?2,188514,188514#msg-188514

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:
http://forum.nginx.org/read.php?2,188514,188556#msg-188556

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/

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
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:
http://forum.nginx.org/read.php?2,188514,188577#msg-188577

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:
http://forum.nginx.org/read.php?2,188514,188695#msg-188695

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. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs