Can't get phpmyadmin and nginx to work :(

  • Posted on May 21, 2013
  • ajAsked by aj

I am new to nginx. I have always used apache. So maybe I don’t know enough about nginx to make this work. I am no newbie to arch though.

I have tried EVERYTHING. Also I have thoroughly searched the forum and google and no, none of the solutions worked. I have a VPS with DigitalOcean (great provider, btw) and I have mariadb, nginx, and php-fpm running perfectly. Everything works. However, I can’t get phpmyadmin to work. I have followed the wiki ([url][/url]) and it still doesn’t work. I keep getting a 403 error. I would provide you with a domain name but I haven’t tied one to the VPS yet. Here is the IP address: [url][/url]

My root directory is /usr/share/nginx/html and if I run an ls /usr/share/nginx/html command I get the following back: index.html phpmyadmin

the directory is obviously there.

My nginx.conf file reads as such: [code] #user html; worker_processes 1;

#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;

#pid logs/;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

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

    #error_page  404              /404.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
    location ~ \.php$ {
	fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
  	fastcgi_index  index.php;
  	root   /usr/share/nginx/html;
  	include        fastcgi.conf;

    # pass the PHP scripts to FastCGI server listening on
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;

server {

listen 80; server_name localhost;

root /usr/share/nginx/html/phpmyadmin; index index.php; fastcgi_index index.php;

location ~ .php$ { include /etc/nginx/fastcgi.conf; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/phpmyadmin$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; }


# another virtual host using mix of IP-, name-, and port-based configuration
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }

# HTTPS server
#server {
#    listen       443;
#    server_name  localhost;

#    ssl                  on;
#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_timeout  5m;

#    ssl_protocols  SSLv2 SSLv3 TLSv1;
#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers   on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }

} [/code]

Any help would be greatly appreciated.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

In my installation, I found that phpMyAdmin wouldn’t work because it uses sessions stored in /var/lib/session, and that directory is owned by the “apache” group, not “nginx” group, so I had to change the ownership on that directory. <br> <br>It happens quite often, changing back to apache, so I suspect there’s a better way to fix it than just changing the ownership of the directory.

Problem resolved. needed to add index.php to locations.