該phpMyAdmin的安裝環境是centos7、nginx、php7.1(php7.1通過centos-release-scl.noarch庫安裝)
1、 yum install phpmyadmin
2、 將phpMyAdmin安裝文件鏈接到網站根目錄
ln -s /usr/shar/phpMyAdmin 網站根目錄
在網站根目錄下使用ls -l
命令可以看到
phpMyAdmin -> /usr/share/phpMyAdmin
3、修改phpMyAdmin安裝文件所屬用戶和用戶組
chown nginx:nginx /usr/share/phpMyAdmin
4、 重啟php-fpm
systemctl restart rh-php71-php-fpm
5、 http://server_domain_or_IP/phpMyAdmin 瀏覽器中打開網址,可能回提示安裝php-mbstring和、php-mysql擴展
yum install rh-php71-php-mbstring
yum install rh-php71-php-mysqlnd
6、 phpMyAdmin的安全設置
- 修改鏈接名稱,以下為舉例
網站根目錄中使用命令
mv phpMyAdmin nothingtosee
則phpMyAdmin界面網址變為http://server_domain_or_IP/nothingtosee - 設置身份驗證
創建加密的密碼,鍵入:
openssl passwd
系統將提示您輸入并確認您要使用的密碼。該實用程序將顯示密碼的加密版本,如下所示:
O5az.RSPzd.HE
復制此值,因為您需要將其粘貼到我們將要創建的認證文件中。
創建一個認證文件:
sudo vi /etc/nginx/pma_pass
輸入以下內容,demo為用戶名
demo:O5az.RSPzd.HE
完成后保存并關閉文件。
修改我們的Nginx配置文件:
sudo nano /etc/nginx/conf.d/default.conf
在這個文件中,我們需要添加一個新的位置部分。這將針對我們為我們的phpMyAdmin界面選擇的位置。server { . . . location /nothingtosee { auth_basic "Admin Login"; auth_basic_user_file /etc/nginx/pma_pass; } . . . }
完成后保存并關閉文件。
重新啟動Web服務器:
systemctl restart nginx