如何在CentOS 7/RHEL 7上安裝phpMyAdmin
阿新 • • 發佈:2018-12-12
phpMyAdmin是用於管理MySQL,MariaDB和Drizzle伺服器的基於Web的管理工具。 它有助於執行資料庫活動,如建立,刪除,查詢,表,列,關係,索引,使用者,許可權等。
在安裝phpMyAdmin之前,必須在伺服器上安裝LAMP Stack。
在CentOS 7上安裝phpMyAdmin
phpMyAdmin在EPEL中可用,因此安裝EPEL儲存庫rpm。
rpm -Uvh https://dl.project.org/pub/epel/epel-release-latest-7.noarch.rpm
使用以下命令安裝phpMyAdmin。
yum -y install phpmyadmin
配置phpMyAdmin
phpMyAdmin將配置檔案放在/etc/httpd/conf.d目錄中。 它具有訪問許可權的規則和許可權。
預設情況下,phpMyAdmin只能從localhost訪問,以改變它; 我們必須編輯phpMyAdmin.conf檔案。
在CentOS 7中,Web訪問由mod_authz_core.c模組管理; 所以正常的允許或拒絕規則即使你修改也行不通。
vi /etc/httpd/conf.d/phpMyAdmin.conf
預設配置如下所示。
Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 127.0.0.1 Require ip ::1 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 127.0.0.1 Require ip ::1 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>
請註釋掉需要ip 127.0.0.1並且要求ip :: 1然後在註釋行中新增要求全部授權,它將如下所示。
Alias /phpMyAdmin /usr/share/phpMyAdminAlias /phpmyadmin /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#Require ip 127.0.0.1
#Require ip ::1
Require all granted
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
<Directory /usr/share/phpMyAdmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
#Require ip 127.0.0.1
#Require ip ::1
Require all granted
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
重啟服務。
systemctl restart httpd
配置防火牆以允許來自外部網路的HTTP請求。
firewall-cmd --permanent --add-service=http firewall-cmd --reload
訪問phpMyAdmin
現在從瀏覽器訪問phpMyAdmin,URL將是:
http://localhost/phpMyAdmin或者
http://your-ip-address/phpMyAdmin使用root(DB admin)或任何資料庫使用者登入。