《MysqL必读在CentOS上安装PHPMyAdmin的教程》要点:
本文介绍了MysqL必读在CentOS上安装PHPMyAdmin的教程,希望对您有用。如果有疑问,可以联系我们。
MysqL实例前提
MysqL实例在CentOS上安装PHPMyAdmin,你第一步需要架设一台Web服务器(如Apache或Nginx),安装好MysqL/MariaDB数据库和PHP.根据你的偏好和需求,你可以从LAMP和LEMP中选择一种安装.
MysqL实例另一个要求是允许在你的CentOS上安装EPEL库.如果你还没设置过请猛戳这里.
在CentOS6或7上安装PHPMyAdmin
MysqL实例一旦你设置了EPEL库,你就能轻松地用以下命令安装PHPMyAdmin了.
MysqL实例在CentOS 7上:
MysqL实例在CentOS 7上:
MysqL实例默认情况下,CentOS 7上的PHPMyAdmin只允许从回环地址(127.0.0.1)访问.为了能远程连接,你需要改动它的配置.
MysqL实例用文本编辑器打开PHPMyAdmin的配置文件(路径:/etc/httpd/conf.d/PHPMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行.会有四处这样的代码行,用"Require all granted"取而代之.重新改动过的配置文件如下所示.
MysqL实例 $ sudo vi /etc/httpd/conf.d/PHPMyAdmin.conf . . . . . <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> . . . . .
MysqL实例最后,重启httpd使改动生效.
MysqL实例默认情况下,CentOS 6上的PHPMyAdmin是禁止从每个IP地址访问的.为了能远程连接,找出并注释掉"Deny from all"字样的代码行.然后把"Allow from 127.0.0.1"字样的代码行改成"Allow from 0.0.0.0".重新改动过的配置文件如下所示.
MysqL实例 $ sudo vi /etc/httpd/conf.d/PHPmyadmin.conf <Directory "/usr/share/PHPmyadmin"> Order Deny,Allow # Deny from all Allow from 0.0.0.0 </Directory>
MysqL实例下一步是将PHPMyAdmin的配置文件用blowfish加密工具加密.这一步需要加密cookie里的密码来作为基于cookie的部分认证.
MysqL实例用文本编辑器打开如下路径所示的文件并且用blowfish设置一个随机密码,如下所示.
MysqL实例 $ sudo vi /usr/share/PHPmyadmin/config.inc.PHP $cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
MysqL实例最后,重启httpd使改动生效.
MysqL实例
$ sudo service httpd restart
MysqL实例测试PHPMyAdmin是否设置成功,访问这个页面:http://<web-server-ip-addresss>/PHPmyadmin
MysqL实例