Forum: NGINX How to configure phpmyadmin with nginx ?

Db1de656c36932b12e29db3b180fe418?d=identicon&s=25 SE7EN (Guest)
on 2009-09-13 00:04
(Received via mailing list)
Hi, phpmyadmin is installed in /usr/share/phpmyadmin and i have the
following vhost configuration file. How to configure phpmyadmin so i can
use: http://mydomain.com/phpmyadminThank youserver {
            listen   80;
            server_name  www.mydomain.com;
    
     #redirect www to non-www
            rewrite ^/(.*) http://mydomain.com/$1 permanent;
            
    
       }


server {
     listen   80;
     server_name mydomain.com;
            access_log /home/mydomain/log/access.log;
            error_log /home/mydomain/log/error.log;
    
    
    
            location /  {
       root   /home/mydomain/public_html/;
       index  index.php index.html;      
       expires 30d;
          
       #stop image and files hotlinking
       location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|jpeg|css)$ {
       valid_referers none blocked mydomain.com www.mydomain.com
*.google.com *.yahoo.com;
       if ($invalid_referer) {
       return 444;
       }
       }
          
       #joomla sef url's
       if (!-e $request_filename) {
         rewrite  ^(.*)$  /index.php?q=$1  last;
         break;
               }
         }
          
       if ( $args ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3d)" ) {
       set $args "";
       rewrite ^.*$ http://$host/index.php last;
       return 403;
       }

       if ( $args ~ "base64_encode.*\(.*\)" ) {
       set $args "";
       rewrite ^.*$ http://$host/index.php last;
       return 403;
       }

       if ( $args ~ "(\<|%3C).*script.*(\>|%3E)" ) {
       set $args "";
       rewrite ^.*$ http://$host/index.php last;
       return 403;
       }
    
       if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
       set $args "";
       rewrite ^.*$ http://$host/index.php last;
       return 403;
       }

       if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
       set $args "";
       rewrite ^.*$ http://$host/index.php last;
       return 403;
       }
         
      
    
            # pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
            location ~ \.php$ 
                  {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME
/home/mydomain/public_html/$fastcgi_script_name;
                        }
       

     ## All other errors get the generic error page
     error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413
414 415 416 417
                 500 501 502 503 504 505 /error_page.html;
     location  $document_root/error_page.html {
     internal;
     
    }
    
    }
96dfd0f0a8399d3b03feba1e6a562e0a?d=identicon&s=25 Edho P Arief (Guest)
on 2009-09-13 08:44
(Received via mailing list)
On Sun, Sep 13, 2009 at 4:54 AM, SE7EN<k1_zeus@yahoo.com> wrote:
>   #redirect www to non-www
>   error_log /home/mydomain/log/error.log;
>

location ~ /phpmyadmin/.*\.php$ {
  root /usr/share/;
  ....php fastcgi settings...;
}

location /phpmyadmin/ {
  root /usr/share/;
  index index.php;
}
Db1de656c36932b12e29db3b180fe418?d=identicon&s=25 SE7EN (Guest)
on 2009-09-13 21:36
(Received via mailing list)
I added this,I verify it, everything is correct, my site works fine but
accessing http://mydomain.com/phpmyadmin still doesn't work, a 500
server errror appears.location ~ /phpmyadmin/.*\.php$ {
                 root /usr/share/;
                 fastcgi_pass 127.0.0.1:9002;
                fastcgi_index index.php;
                include /usr/local/nginx/conf/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME
/usr/share/phpmyadmin$fastcgi_script_name;
                }

                location /phpmyadmin/ {
                root /usr/share/;
                index index.php;
                }



--- On Sun, 9/13/09, Edho P Arief <edhoprima@gmail.com> wrote:

From: Edho P Arief <edhoprima@gmail.com>
Subject: Re: How to configure phpmyadmin with nginx ?
To: nginx@sysoev.ru
Date: Sunday, September 13, 2009, 9:31 AM

On Sun, Sep 13, 2009 at 4:54 AM, SE7EN<k1_zeus@yahoo.com> wrote:
>   #redirect www to non-www
>   error_log /home/mydomain/log/error.log;
>

location ~ /phpmyadmin/.*\.php$ {
  root /usr/share/;
  ....php fastcgi settings...;
}

location /phpmyadmin/ {
  root /usr/share/;
  index index.php;
}
F7ec36678a4102de7a6895d299a60819?d=identicon&s=25 Ian Hobson (Guest)
on 2009-09-14 00:03
(Received via mailing list)
Hi se7en,

Your location line is incorrect and you may need a line to send php over
also. Try the following inside your server directive.

index index.php index.htm index.html;
location   ^~ /phpmyadmin/ {
   root /usr/share;
   include /????/fastcgi_params;
   fastcgi_pass  127.0.0:9002;
}
location ~ \.php {
    include  /????/fastcgi_params;
    fastcgi_pass  127.0.0.1:9002;
}

Don't forget to replace the ??? with the correct path - mine is
/etc/nginx/ and check that phpmyadmin
has been installed in /usr/share/phpmyadmin - or adjust the root.

Regards

Ian
Db1de656c36932b12e29db3b180fe418?d=identicon&s=25 SE7EN (Guest)
on 2009-09-14 10:01
(Received via mailing list)
I don't know what tot say, here is my config file (after the sample with
subdomain that works) but it still doesn't work. phpmyadmin is installed
in /usr/share/phpmyadmin and site works fine, so it's no error in my
config file. it works only when I create a new vhost file like this and
access phpmyadmin as a subdomain


server {
    listen 80;
    server_name phpmyadmin.domainname.com;
    access_log  /home/apps/logs/phpmyadmin.access_log;
    error_log  /home/apps/logs/phpmyadmin.error_log;

    location / {
         root /usr/share/phpmyadmin;
         index index.php;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:8888;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME
/usr/share/phpmyadmin$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;
    }
}

vhost.conf
server {
            listen   80;
            server_name  www.mydomain.com;

                        #redirect www to non-www
            rewrite ^/(.*) http://mydomain.com/$1 permanent;


       }


server {
                        listen   80;
                        server_name mydomain.com;
            access_log /home/mydomain/log/access.log;
            error_log /home/mydomain/log/error.log;

            index index.php index.htm index.html;
location   ^~ /phpmyadmin/ {
  root /usr/share;
  include /usr/local/nginx/conf/fastcgi_params;
  fastcgi_pass  127.0.0:9002;
}

location /  {
                                root   /home/mydomain/public_html/;
                                index  index.php index.html;
                                expires 30d;

                                #stop image and files hotlinking
                                location ~*
^.+\.(gif|jpg|png|swf|flv|rar|zip|jpeg|css)$ {
                                valid_referers none blocked mydomain.com
www.mydomain.com *.google.com *.yahoo.com;
                                if ($invalid_referer) {
                                return 444;
                                }
                                }

                                #joomla sef url's
                                if (!-e $request_filename) {
                                        rewrite  ^(.*)$  /index.php?q=$1
last;
                                        break;
                                                                }
                                        }

                                if ( $args ~
"mosConfig_[a-zA-Z_]{1,21}(=|\%3d)" ) {
                                set $args "";

rewrite ^.*$ http://$host/index.php last;
                                return 403;
                                }

                                if ( $args ~ "base64_encode.*\(.*\)" ) {
                                set $args "";
                                rewrite ^.*$ http://$host/index.php
last;
                                return 403;
                                }

                                if ( $args ~
"(\<|%3C).*script.*(\>|%3E)" ) {
                                set $args "";
                                rewrite ^.*$ http://$host/index.php
last;
                                return 403;
                                }

                                if ( $args ~
"GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
                                set $args "";
                                rewrite ^.*$ http://$host/index.php
last;
                                return 403;
                                }

                                if ( $args ~
"_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
                                set $args "";
                                rewrite ^.*$ http://$host/index.php
last;
                                return 403;
                                }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9002
            location ~ \.php$
                                {
            fastcgi_pass 127.0.0.1:9002;
            fastcgi_index index.php;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME
/home/digitalfav/public_html/$fastcgi_script_name;
                        }


                        ## All other errors get the generic error page
                        error_page 400 401 402 403 404 405 406 407 408
409 410 411 412 413 414 415 416 417
                 500 501 502 503 504 505 /error_page.html;
                        location  $document_root/error_page.html {
                        internal;

                 }

                 }


--- On Mon, 9/14/09, Ian Hobson <ian@ianhobson.co.uk> wrote:

From: Ian Hobson <ian@ianhobson.co.uk>
Subject: Re: How to configure phpmyadmin with nginx ?
To: nginx@sysoev.ru
Date: Monday, September 14, 2009, 12:52 AM

Hi se7en,

Your location line is incorrect and you may need a line to send php over
also. Try the following inside your server directive.

index index.php index.htm index.html;
location   ^~ /phpmyadmin/ {
  root /usr/share;
  include /????/fastcgi_params;
  fastcgi_pass  127.0.0:9002;
}
location ~ \.php {
   include  /????/fastcgi_params;
   fastcgi_pass  127.0.0.1:9002;
}

Don't forget to replace the ??? with the correct path - mine is
/etc/nginx/ and check that phpmyadmin
has been installed in /usr/share/phpmyadmin - or adjust the root.

Regards

Ian
Db1de656c36932b12e29db3b180fe418?d=identicon&s=25 SE7EN (Guest)
on 2009-09-14 10:13
(Received via mailing list)
I think i got it, if i add this, it works but the images of phpmyadmin
don't show, maybe a permission issue ?
ndex index.php index.htm index.html;
location   ^~ /phpmyadmin/ {
  root /usr/share;
  include /usr/local/nginx/conf/fastcgi_params;
  fastcgi_pass  127.0.0:9002;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}



--- On Mon, 9/14/09, Ian Hobson <ian@ianhobson.co.uk> wrote:

From: Ian Hobson <ian@ianhobson.co.uk>
Subject: Re: How to configure phpmyadmin with nginx ?
To: nginx@sysoev.ru
Date: Monday, September 14, 2009, 12:52 AM

Hi se7en,

Your location line is incorrect and you may need a line to send php over
also. Try the following inside your server directive.

index index.php index.htm index.html;
location   ^~ /phpmyadmin/ {
  root /usr/share;
  include /????/fastcgi_params;
  fastcgi_pass  127.0.0:9002;
}
location ~ \.php {
   include  /????/fastcgi_params;
   fastcgi_pass  127.0.0.1:9002;
}

Don't forget to replace the ??? with the correct path - mine is
/etc/nginx/ and check that phpmyadmin
has been installed in /usr/share/phpmyadmin - or adjust the root.

Regards

Ian
0a09f8d706b212e7ec75cc84e9f561cd?d=identicon&s=25 Artifex Maximus (Guest)
on 2009-09-14 15:27
(Received via mailing list)
Hello!
I had the same problem and Igor said that nginx does not handle (yet?)
nested locations. So you have to write in this way:

location /phpmyadmin/ {
alias /usr/share/phpmyadmin/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
alias /usr/share/phpmyadmin/$1;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}

Bye,
a
F7ec36678a4102de7a6895d299a60819?d=identicon&s=25 Ian Hobson (Guest)
on 2009-09-14 15:45
(Received via mailing list)
SE7EN wrote:
>
> I think i got it, if i add this, it works but the images of phpmyadmin
> don't show, maybe a permission issue ?
>
>
Improbable and easy to check  - the server only needs read access.

More likely IMO, is that phpmyadmin is asking for them in the wrong
place.
Take a look at the source of a phpmyadmin page.

My logon screen contains

<img src="./themes/original/img/logo_right.png
<view-source:http://212.13.194.210/phpmyadmin/themes/original/i...
id="imLogo" .. etc

that is served from

/src/share/phpmyadmin/themes/original/img/logo_right.png


If you request

themes/original/img/logo_right.png
and
phpmyadmin/phpmyadmin/themes/original/img/logo_right.png

you will find out which.

> dex index.php index.htm index.html;
> location   ^~ /phpmyadmin/ {
>   root /usr/share;
>   include /usr/local/nginx/conf/fastcgi_params;
>   fastcgi_pass  127.0.0:9002;
>
Did you mean 127.0.0.1:9002?
>
> }
>
>
> location ~ \.php$ {
> fastcgi_pass 127.0.0.1:9002;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;
>
This ^^^ line is redundant because there is a line containing

fastcgi_params SCRIPT_FILENAME $document_root$fastcgi_script_name;

in the included file below, that will result in the same thing.

Ian
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.