在 Nginx Web Server 上使用 phpmyadmin

本篇文章參考:凍仁的筆記: 限制 phpMyAdmin 存取 IP on Debian 6

安裝 phpmyadmin
# apt-get install phpmyadmin
似乎預設只支援 Apache 2 / Lighttpd
[@more@]手動設定 Nginx Web Server
# vim /etc/nginx/nginx.conf
         location /phpmyadmin {
                allow 192.168.1.0/24;
                deny all;
                root /usr/share;
                index index.php index.html index.htm;
                location ~ ^/phpmyadmin/(.+.php)$ {
                    try_files $uri =404;
                    root /usr/share;
                    #fastcgi_pass 127.0.0.1:9000;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME /usr/share/$fastcgi_script_name;
                    include fastcgi_params;
                }
                location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                    root /usr/share/;
                }
            }
            location /phpMyAdmin {
                        rewrite ^/* /phpmyadmin last;
            }

重新啟動 Nginx Web Server
# /etc/init.d/nginx restart

使用瀏覽器來觀看