0

I've installed Nginx, php-fpm, mysql and phpmyadmin..

When I type myserver.com I see "Welcome to nginx!".

But when I type myserver.com/phpmyadmin, I got : "No input file specified. ". I know it's probably a problem with the path, but I can't find where... :S

Config file:

/etc/nginx/sites-available/default

server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.php  index.html index.htm;

        # Make site accessible from http://localhost/
        server_name _;

        location / {

                try_files $uri $uri/ /index.html;

        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
                deny all;
        }


        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                #fastcgi_pass 127.0.0.1:9000;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

/etc/nginx/sites-availables/www.myserver.com.vhost

server {
       listen 80;
       server_name www.server.com server.com;
       root /usr/share/nginx/www.akdom.net;
       if ($http_host != "www.akdom.net") {
                 rewrite ^ http://www.akdom.net$request_uri permanent;
       }
       index index.php index.html;
       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }
       # Make sure files with the following extensions do not get loaded by nginx because nginx would display the s$
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..$
                deny all;
        }
       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }
       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }
       location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
}

In /usr/share/ I have phpmyadmin/, nginx/www/ and nginx/www.exemple.com/

How to fix this error? What is causing it?

Thanks for your time.

Jeremy Dicaire
  • 165
  • 1
  • 5
  • 15

2 Answers2

1

On file /etc/nginx/sites-availables/www.myserver.com.vhost

Change the line root /usr/share/; inside location /phpmyadmin to: root /usr/share/phpmyadmin/;

  • Thanks for your reply. I felt stupid fore a minute, but it still not working (I ran /etc/init.d/nginx restart). I tried www.exemple.com too (instead of exemple.com which give the default index page located in www) and it's not working either (Server not found). don't know why my index.php page in my www.exemple.com folder is not showing up. (+1 for your answer) – Jeremy Dicaire Jul 06 '13 at 18:33
0

You're a victim of location selection rules here.

In order to get this working you need to make your location /phpmyadmin higher preference than location ~ .php$. To do this we have to consider what the documentation says about location.

Basically the only locations more specific than a regex location are exact match = and the negative regex location ^~

Exact matching is not a good options here so we need to use the negative regex location.

    location ^~ /phpmyadmin {
           root /usr/share;
           index index.php index.html index.htm;

           location ~ \.php$ {
                   try_files $uri =404;

                   fastcgi_pass 127.0.0.1:9000;

                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }

           location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
                   root /usr/share; # If you're only setting root then this is not needed.
           }

           location ~ /\. { # We need to duplicate this so that we don't serve htaccess/passwd files for this subdir.
                   deny all;
                   access_log off;
                   log_not_found off;
           }
    }
Martin Fjordvald
  • 7,749
  • 1
  • 30
  • 35