Running phpmyadmin on non-standard dir

hi. I’m new to Nginx.
I’d like to make serve phpmyadmin on a non-standard url.
I’m on debian, and following this howto works great:
http://rubyist-journal.com/2010/02/28/howto-nginx-php5-mysql-phpmyadmin-ubuntu-shortest-setup/

but if I change it this way:

location /pma {
       root /usr/share/phpmyadmin/;
       index index.php index.html index.htm;
       location ~ ^/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/phpmyadmin/;
               fastcgi_pass   backend;
               fastcgi_param HTTPS $fastcgi_https;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME

$document_root$request_filename;
include /etc/nginx/fastcgi_params;
}
}

I just get 404.
2 questions:

  • how to make it properly work?
  • how to debug these config errors?

thanks a lot!
maxxer

Posted at Nginx Forum:

(complete answer on the bottom)

On Fri, Feb 3, 2012 at 5:01 PM, maxxer [email protected] wrote:

hi. I’m new to Nginx.
I’d like to make serve phpmyadmin on a non-standard url.

There’s no “standard url”. Learn how “root” (and “alias”) directive
work.

  • how to make it properly work?

http://wiki.nginx.org/HttpCoreModule
http://wiki.nginx.org/HttpFcgiModule

  • how to debug these config errors?

http://wiki.nginx.org/HttpLogModule
http://wiki.nginx.org/CoreModule

location = /pma { rewrite ^ /pma/ permanent; }
location /pma/ {
location /pma/(..php)$ {
set $script_filename /usr/share/phpmyadmin/$1;
# testing file existence for security.
# sadly in this case we can’t use try_files since we’re testing
against actual file on disk
# while try_files tries against uri
if (!-f $script_filename) { return 404; }
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $script_filename;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_pass backend;
}
location ~ ^/pma(|/.
)$ {
alias /usr/share/phpmyadmin/$1;
index index.php;
}
}


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

http://www.howtoforge.com/running-phpmyadmin-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04

Works with cgi.fix_pathinfo on and off.

----- Original Message -----
From: “maxxer” [email protected]
To: [email protected]
Sent: Friday, February 03, 2012 11:01 AM
Subject: running phpmyadmin on non-standard dir

Falko T. Wrote:

http://www.howtoforge.com/running-phpmyadmin-on-ng
inx-lemp-on-debian-squeeze-ubuntu-11.04

Works with cgi.fix_pathinfo on and off.

thanks Falko, I’m usually a great fan of your howtos, but I with to
serve phpmyadmin on the url /pma instead of /phpmyadmin, and I wasn’t
able to tweak the config to do this…

Edho thanks, but your config makes the /pma url redirect to /phpmyadmin,
and download the source of index.php.

Posted at Nginx Forum:

On Fri, Feb 3, 2012 at 5:59 PM, maxxer [email protected] wrote:

Edho thanks, but your config makes the /pma url redirect to /phpmyadmin,
and download the source of index.php.

Sorry, I forgot a tilde.

location ~ /pma/(.*.php)$ {


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

If you are inexperienced, do not run phpmyadmin publically as
/phpmyadmin or you will fall behind a security update to find your
system compromised (and now the new member in the botnet!) I used to
hunt botnets for awhile and PhpMyAdmin was a common way to get in

On 3 Fev 2012 16h10 WET, [email protected] wrote:

If you are inexperienced, do not run phpmyadmin publically as
/phpmyadmin or you will fall behind a security update to find your
system compromised (and now the new member in the botnet!) I used to
hunt botnets for awhile and PhpMyAdmin was a common way to get in

Yep. There’s a FD post by the Gentoo security team that exposes what
an utter complete wreck security wise phpmyadmin is:

Use Chive: http://www.chive-project.com

Don’t forget to set: cgi.fix_pathinfo = 0 on the php.ini.

You’re gaining something in security terms by choosing Nginx over
Apache, don’t throw that under a bus by using phpmyadmin.

— appa