nginx配置phpmyadmin备忘

2017-11-23 22:12:00
wyd621
原创 0

使用nginx配置phpmyadmin时,一直无法显示。配置如下

server {
        listen   80;
        server_name  localhost;

        access_log  /var/log/nginx/localhost.access.log;

        location / {
                root   /home/www/colinux;
                index  index.php index.html index.htm;
        }

        location /doc {
                root   /usr/share;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        location /images {
                root   /usr/share;
                autoindex on;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /var/www/nginx-default;
        }

        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /home/www/colinux$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }

        location /phpmyadmin/ {
                root   /home/www/;
        }

        location ~ /\.ht {
                deny  all;
        }

查看错误日志发现这样的报错:

directory index of "/home/www/phpmyadmin/" is forbidden

刚开始以为是权限问题,可惜走错了方向。

最后发现原来没有指定index,加上就好了。就行下面一样。

      location /phpmyadmin/ {
                root   /home/www;
                index index.php index.html index.htm;

                location ~ \.php$ {
                        fastcgi_pass   127.0.0.1:9000;
                        fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME  /home/www$fastcgi_script_name;
                        include /etc/nginx/fastcgi_params;
                }

        }

发表评论
评论通过审核后显示。