cosmoonot
cosmoonot

Reputation: 2189

phpMyAdmin 404 error on Digital Ocean hosting

I'm getting a 404 error after install phpMyAdmin using Digital Ocean's guide. I have multiple domains setup on Ubuntu running nginx. There is a phpmyadmin directory within /var/www/. The only difference from the guide was the following command:

sudo ln -s /usr/share/phpmyadmin/ /var/www

Do I need to add server block possibly? Since I have multiple domains, each of them has a separate configuration file.

Sample config file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/domain1.com/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name MY_IP_ADDRESS;

    location / {
        try_files $uri $uri/ =404;
    }

    location /phpmyadmin {
        root     /var/www/;
        index index.php index.html;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
        include        fastcgi_params;
        try_files      $uri /index.php;
    }

    location ~ /\.ht {
        deny all;
    }
}

I'm not great at server administration. Any suggestions?

Upvotes: 2

Views: 951

Answers (1)

Sahil Gulati
Sahil Gulati

Reputation: 15141

Define this server block it worked for me. A basic configuration for phpmyadmin in you case.As you have created a symbolic link in /var/www.

sudo ln -s /usr/share/phpmyadmin/ /var/www

server {

    listen 80;
    server_name website.in www.website.in;
    autoindex on;

    location /phpmyadmin {
        root /var/www/;
        index index.php index.html;

        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
            include        fastcgi_params;
            try_files      $uri $uri/ /index.php;
        }
    }   

    location / {
        root /var/www/your/path;
        index index.php index.html;

        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php5-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            include        fastcgi_params;
            try_files      $uri $uri/ /index.php;
        }
    }
}

Upvotes: 1

Related Questions