CentOS6/7上phpmyadmin安装和配置总结 配合apache2.4

前端之家收集整理的这篇文章主要介绍了CentOS6/7上phpmyadmin安装和配置总结 配合apache2.4前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PHPmyadmin是MysqL/mariadb的网页版管理工具。

安装PHPMyAdmin

epel库里面包含了PHPMyAdmin,可直接yum安装使用。

#yum install epel-release 
#yum install PHPMyAdmin  PHP-mbstring PHP-mcrypt

PHPMyAdmin默认的安装目录:/usr/share/PHPMyAdmin
创建的配置文件:/etc/httpd/conf.d/PHPMyAdmin.conf

配置PHPMyAdmin

1. 设置cookie加密字符串

#vi /usr/share/PHPMyAdmin/libraries/config.default.PHP

$cfg[‘blowfish_secret’] = ‘blog.csdn.net.blog.csdn.net.blog.csdn.net.blog.csdn.net’;

加密字符串推荐设置成32位,太短的话PHPMyAdmin仍然有警告。

2. 设置session文件夹权限

不设置权限,会有错误提示

#chmod -R apache:apache /var/lib/PHP/session

其中apache是httpd服务器的用户

3. 放开IP限制(适用于apache 2.4)

#vi /etc/httpd/conf.d/PHPMyAdmin.conf

注释这两行
Require ip 127.0.0.1
Require ip ::1
加上Require all granted

[root@localhost PHPMyAdmin]# cat /etc/httpd/conf.d/PHPMyAdmin.conf
# PHPMyAdmin - Web based MysqL browser written in PHP
#
# Allows only localhost by default
#
# But allowing PHPMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

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
        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>

# These directories do not require access over HTTP - taken from the original
# PHPMyAdmin upstream tarball
#
<Directory /usr/share/PHPMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/PHPMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

<Directory /usr/share/PHPMyAdmin/setup/frames/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>

# This configuration prevents mod_security at PHPMyAdmin directories from
# filtering sql etc. This may break your mod_security implementation.
#
#<IfModule mod_security.c>
# <Directory /usr/share/PHPMyAdmin/>
# SecRuleInheritance Off
# </Directory>
#</IfModule>

设置后,就可以远程打开PHPmyadmin的网址,输入MysqL/mariadb的用户名和密码,即可管理数据库

猜你在找的CentOS相关文章