1

[Tried all answers on Stackoverflow, and searched on google a lot, but none of the configurations worked.]

I've installed LEMP server on Fedora using the guide on DigitalOcean (https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6). Replaced example.com in nginx's default.conf to localhost.

Then, I installed phpMyAdmin using this (https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server).

The nginx web directory is /usr/share/nginx/html. I've created a symbolic link for phpmyadmin. It's at /usr/share/nginx/html/phpMyAdmin.

Currently, I just need localhost access (localhost/phpmyadmin). I'm able to access localhost, and localhost/info.php.

I tried many configurations, one of them below: Nginx location directive doesn't seem to be working. Am I missing something?

But it doesn't work. Sometimes I get "No input file specified." and other times 404 not found. I'd like to have the access at localhost/phpmyadmin.

Edit: My default.conf file. Getting a "No input file specified." error in browser.

#
# The default server
#
server {
    #listen       80 default_server;
    listen  80;
    server_name localhost;
    #server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;
    }

    location /phpmyadmin {
        alias /usr/share/nginx/html/phpMyAdmin;
        index index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ /phpMyAdmin/.*\.php$ {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME /usr/share/nginx/html/$uri;
        include     fastcgi_params;
    }

    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

Thanks.

HyprGeek
  • 13
  • 1
  • 4
  • Can you post your current nginx config for review? – Alan Ivey Mar 16 '13 at 19:12
  • Added the conf file. – HyprGeek Mar 16 '13 at 20:12
  • Does http://localhost/phpMyAdmin (watch out for case) work? You alias the mixed-case version for static files (`location /phpmyadmin`), but not for the `location /phpMyAdmin/.*\.php$` block. You should also have a look at the **permissions** for the _real_ phpMyAdmin directory. – Lukas Mar 17 '13 at 04:01
  • localhost/phpMyAdmin gives an internal 500 server error. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. Permissions for the real phpMyAdmin directory (in /usr/share/) are: drwxr-xr-x. 8 root root 4096 Mar 16 17:31 phpMyAdmin – HyprGeek Mar 17 '13 at 04:14

1 Answers1

1

For your 404, you should make the character cases match either all phpmyadmin (all lower case) or phpMyAdmin.

To make the config clearer (my opinion), you could use nested locations:

location /phpmyadmin/ {
    index index.php index.html index.htm;

    location ~ \.php$ {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME /usr/share/nginx/html/$uri;
        include     fastcgi_params;
    }
}

You then have to relink phpMyAdmin in your webroot (note the missing alias directive):

unlink /usr/share/nginx/html/phpMyAdmin
ln -s /usr/share/phpMyAdmin /usr/share/nginx/html/phpmyadmin


Alternatively, to keep the mixed-case link, add this line to the above location /phpmyadmin to internally change the $uri (required to find the files):
rewrite ^/phpmyadmin(.*)$ /phpMyAdmin$1;


To fix the 500, you might want to check out another answer on SF about PHP restrictions. I just now realized that executing PHP scripts outside the webroot can trigger security mechanisms.
That would then be a PHP error, meaning that the location matches.
Lukas
  • 1,004
  • 6
  • 14
  • Hi, I tried your config above (except for the rewrite statement). Looks like the location matches now, but I'm getting the following error. phpMyAdmin - Error Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. – HyprGeek Mar 20 '13 at 04:00
  • Hey, I'm now able to access phpmyadmin. But it still looks like something is not right, I'm unable to create database or add/edit users, the request keeps going on if I click Create button to create a db. Thanks. – HyprGeek Mar 27 '13 at 10:21
  • Hi, I finally figured out the problem. The auth_type in /etc/phpMyAdmin/config.inc.php was set to http. I set it to cookie, and changed ownership of /var/lib/php/session to nginx:nginx. Now, it works. Thanks a lot. – HyprGeek Mar 27 '13 at 11:50