CentOS 8目前只能採用tarball的安裝法。
必要條件
PHP >=7,Mysql/ Mariadb 已安裝,防火牆80埠有開
安裝php相關組件
# yum install php php-pdo php-pecl-zip php-json php-common php-fpm php-mbstring php-cli php-mysqlnd
下載phpmyadmin tarball
下載頁面 https://www.phpmyadmin.net/downloads/
例如到你的安裝目錄下
# cd /var/www/html # wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.zip
解壓
# unzip phpMyAdmin-5.1.0-all-languages.zip
更名
# mv phpMyAdmin-5.1.0-all-languages phpMyAdmin
修改 phpMyAdmin 設定檔
需要把 config.sample.inc.php 複製成 config.inc.php,到 phpMyAdmin的目錄下
# cp config.sample.inc.php config.inc.php
修改設定檔
# vi config.inc.php
填入bluefish的key,不能留空白,請開啟以下網頁取得 Bluefish 的 key,
https://phpsolved.com/phpmyadmin-blowfish-secret-generator/
安裝完成並登入
限定讀取來源 192.168.1.0/24
# vi /etc/httpd/conf.d/phpMyAdmin.conf <Directory /var/www/html/phpMyAdmin/> AddDefaultCharset UTF-8 SSLRequireSSL //強迫使用https <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 192.168.1.0/24 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 182.168.1.0/24 </IfModule> </Directory> <Directory /var/www/html/phpMyAdmin/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 192.168.1.0/24 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 192.168.1.0/24 </IfModule> </Directory>
重啟 apache 生效
# systemctl restart httpd
開啟網頁 http://x.x.x.x/phpmyadmin <== 上面設的別名
selinux
# setsebool httpd_can_network_connect_db on