phpMyAdmin 404在Digital Ocean托管上出错

时间:2017-02-23 02:49:21

标签: nginx phpmyadmin digital-ocean

我使用Digital Ocean的guide安装phpMyAdmin后出现404错误。我在运行nginx的Ubuntu上设置了多个域。 / var / www /中有一个phpmyadmin目录。与指南的唯一区别是以下命令:

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

我可能需要添加服务器块吗?由于我有多个域,因此每个域都有一个单独的配置文件。

示例配置文件:

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;
    }
}

我在服务器管理方面表现不佳。有什么建议?

1 个答案:

答案 0 :(得分:1)

定义它为我工作的服务器块。 在你的情况下phpmyadmin的基本配置。你已经在/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;
        }
    }
}