Linux 系统 安装 phpMyAdmin
2017-12-13 00:03
357 查看
在CentOS6或7上安装phpMyAdmin
一旦你设置了EPEL库,你就能轻松地用以下命令安装phpMyAdmin了。在CentOS 7上:
$ sudo yum install phpmyadmin
在CentOS 7上:
$ sudo yum install phpmyadmin php-mcrypt
在CentOS 7上配置phpMyAdmin
默认情况下,CentOS 7上的phpMyAdmin只允许从回环地址(127.0.0.1)访问。为了能远程连接,你需要改动它的配置。用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之。重新改动过的配置文件如下所示。
$ 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
OrderDeny,Allow
DenyfromAll
Allowfrom127.0.0.1
Allowfrom::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
OrderDeny,Allow
DenyfromAll
Allowfrom127.0.0.1
Allowfrom::1
</IfModule>
</Directory>
.....
最后,重启httpd使改动生效。
$ sudo systemctl restart httpd
在CentOS 6上配置phpMyAdmin
默认情况下,CentOS 6上的phpMyAdmin是禁止从每个IP地址访问的。为了能远程连接,你需要改动它的配置。用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉"Deny from all"字样的代码行。然后把"Allow from 127.0.0.1"字样的代码行改成"Allow from 0.0.0.0"。重新改动过的配置文件如下所示。
$ 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>
下一步是将phpMyAdmin的配置文件用blowfish加密工具加密。这一步需要加密cookie里的密码来作为基于cookie的部分认证。
用文本编辑器打开如下路径所示的文件并且用blowfish设置一个随机密码,如下所示。
$ sudo vi /usr/share/phpmyadmin/config.inc.php
$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU
MUST FILL IN THIS FOR COOKIE AUTH! */
最后,重启httpd使改动生效。
$ sudo service httpd restart
测试phpMyAdmin
测试phpMyAdmin是否设置成功,访问这个页面:http://<web-server-ip-addresss>/phpmyadmin你应该能通过Web界面来记录下任何MySQL用户(比如root)和管理MySQL/MariaDB的数据库/表。
疑难解答
这里有一些在CentOS上安装phpMyAdmin的过程中遇到的一些问题解决方法。当你在浏览器里尝试连接phpMyAdmin页面的时候,你看到"403 Forbidding"错误:
You don't have permission to access /phpMyAdmin on this server.
发生这种错误是因为phpMyAdmin默认阻止了IP地址远程连接。要修复这种错误,你需要编辑它的配置文件来允许远程连接。具体操作见上。
当你连接phpMyAdmin页面时,你看见"The configuration file now needs a secret passphrase (blowfish_secret)."信息,并且你无法登录。
要修复这种错误,你需要编辑 /usr/share/phpmyadmin/config.inc.php 这个文件来添加一个随机的blowfish密码,然后重启httpd,如下所示。
$cfg['blowfish_secret']='kd5G}d33aXDc50!';/* YOU
MUST FILL IN THIS FOR COOKIE AUTH! */
$ sudo service httpd restart (CentOS6)
$ sudo systemctl restart httpd (CentOS7)
当你连接phpMyAdmin页面时,你看见"Cannot load mcrypt extension. Please check your PHP configuration"错误信息。
要修复这种错误,要安装下面这个包:
$ sudo yum install php-mcrypt
然后重启httpd:
$ sudo service httpd restart (CentOS6)
$ sudo systemctl restart httpd (CentOS7)
相关文章推荐
- Linux系统入门学习:在CentOS上安装phpMyAdmin
- Linux系统下安装phpmyadmin方法
- Linux系统安装phpMyAdmin
- Linux系统下安装phpmyadmin方法
- Linux系统下安装phpmyadmin方法
- Linux系统下安装phpmyadmin方法
- Linux系统下安装phpmyadmin方法
- Linux系统之CentOS6.5最小安装后的配置
- .net core系列 一linux系统安装
- Linux系统中rar、unrar命令安装和使用详解
- Linux虚拟系统安装VMware Tools总结
- Linux下 php5 MySQL5 Apache2 phpMyAdmin ZendOptimizer安装与配置[图文]
- 关于linux下安装oracle之后,重启系统后oracle不能正常启动的配置总结
- Linux与Windows双系统下的Grub引导管理器安装
- Windows10中Virtualbox没办法选择和安装64位的Linux系统
- CentOS 6.4下安装和配置Samba 第2页_服务器应用_Linux公社-Linux系统门户网站
- linux的系统环境安装
- 在VMware虚拟机里安装Linux系统
- 如何安装linux系统
- 17制作U盘启动盘安装Linux系统_Fedora17