centos7 安装phpmyadmin

前提

在CentOS上安装phpMyAdmin,你第一步需要架设一台Web服务器(如Apache或nginx),安装好MySQL/MariaDB数据库和PHP。根据你的偏好和需求,你可以从LAMP和LEMP中选择一种安装。

 

先安装epel,不然安装pgpmyadmin时会出现找不到包。

yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

 

安装

sudo yum install phpmyadmin

在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

 

修改后的文件内容

 

 
  1. AddDefaultCharset UTF-8

  2.  
  3. # Apache 2.4

  4. # Require ip 127.0.0.1 #注释掉

  5. # Require ip ::1 #注释掉

  6. Require all granted #新添加

  7. # Apache 2.2

  8. Order Deny,Allow

  9. Deny from All

  10. Allow from 127.0.0.1

  11. Allow from ::1

  12.  
  13. # Apache 2.4

  14. #Require ip 127.0.0.1 #注释掉

  15. #Require ip ::1 #注释掉

  16. Require all granted #新添加

  17. # Apache 2.2

  18. Order Deny,Allow

  19. Deny from All

  20. Allow from 127.0.0.1

  21. Allow from ::1

 

 

 

最后,重启httpd使改动生效。

 

sudo systemctl restart httpd

 

 

测试

 

ip/phpmyadmin

你可能感兴趣的:(php,mysql,Linux)