通過homebrew安裝phpmyadmin, 安裝完成後, phpmyadmin只給出了下面的提示
==> Caveats
Note that this formula will NOT install mysql. It is not
required since you might want to get connected to a remote
database server.
Webserver configuration example (add this at the end of
your /etc/apache2/httpd.conf for instance) :
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then, open http://localhost/phpmyadmin
並沒有說明nginx如何配置, 原來的做法, 是單獨為phpmyadmin配置apache監聽8080端口.
但是感覺有些麻煩, 如果能只開nginx的話, 還是只開nginx.
nginx的配置如下, 彩添加一個vhost的辦法.
server {
listen 80;
server_name db.local;
root /usr/local/share/phpmyadmin;
index index.html index.htm index.php;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
在/etc/hosts
文件中添加一條hosts記錄
127.0.0.1 db.local
然後重啟nginx即可.
訪問db.local後, 使用root用戶名, 空密碼, 出現 #2002錯誤. 網上查詢一下, 發現如下解決辦法.