phpMyAdmin for CentOS6.5安装、配置与使用

一、phpMyAdmin介绍

提到界面化的管理工具,phpMyAdmin就必须要提到,是一款用PHP语言开发,基于B/S架构,用于管理mysql的专业工具。而且伴随着PHP和mysql的发展,phpMyAdmin用的会越来越多,类似的其他php[XX]admin工具也越来越多,这类工具基于浏览器的WEB界面方式操作,与平台无关,功能强大,一直有更新。

phpMyAdmin的官方网站: http://www.phpmyadmin.net/
维基百科中对其的描述信息: http://en.wikipedia.org/wiki/PhpMyAdmin


 二、解压方式安装phpmyadmin 
phpMyAdmin工具自身安装简单,解压即可使用。但PHP语言穾一套Apache+PHP环境,需要单独搭建。
为了免于搭建可以安装XAMPP软件包,包含Apache、MySQL、Perl、PHP及各种相关的软件包。XAMMP就象一套封装好的服务器端,在任何平台都是下载、解压、启动,即可拥有一套 apache/mysql/php/perl 已经各项关联软件包的运行环境。


XAMPP下载地址为: http://www.apachefriends.org/zh_cn/xampp.html
XAMPP安装介质安装不同的操作系统分为不同的类型,Windows下为exe安装文件,Linux下为 .run结尾的安装文件,之前的版本还有 xampp-linux-1.8.1.tar.gz 的压缩文件,直接解压即可使用。


按照 xampp-linux-1.8.1.tar.gz 压缩包安装过程如下:
# su - root  
# cd /usr/local/src/  
# wget http://nchc.dl.sourceforge.net/project/xampp/XAMPP%20Linux/1.8.1/xampp-linux-1.8.1.tar.gz  
# tar xvfz xampp-linux-1.8.1.tar.gz -C /opt  


安装默认只能本地访问phpMyAdmin服务器,需要进行如下配置让所有服务器都可以访问:
# vi /opt/lampp/etc/extra/httd-xampp.conf
在<Directory "/opt/lampp/phpmyadmin">标签中(16-19行之间)增加一行:
Require all granted
将<LocationMatch>标签中第62行:
Deny from all
改为:
Allow from all
保存后退出。 

解压后会在/opt目录创建一个名为lampp的目录,需要用到的工具都在里面。但需要注意,1.8.2版本之前,XAMPP默认只支持32位操作系统,如果再64位系统中使用,要么安装glib-xx-.i686软件包,要么使用高版本的XAMPP。

三、命令安装方式安装phpMyAdmin
如果是 xampp-linux-x64-1.8.3-4-installer.run安装文件,安装与设置过程如下:
ftp  xampp-linux-x64-1.8.3-4-installer.run /opt
# cd /opt
# chmod +x xampp-linux-x64-1.8.3-4-installer.run
# ./xampp-linux-x64-1.8.3-4-installer.run 
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.
----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want 
to install. Click Next when you are ready to continue.
XAMPP Core Files : Y (Cannot be edited)
XAMPP Developer Files [Y/n] :Y   
Is the selection above correct? [Y/n]: 
----------------------------------------------------------------------------
Installation Directory
XAMPP will be installed to /opt/lampp
Press [Enter] to continue :
----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.
Do you want to continue? [Y/n]: Y
----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.
 Installing
 0% ______________ 50% ______________ 100%
 #########################################
----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.


在1.8.3版本中,第一个修改已经变化了,对于LocationMatch中,也只用一个“Require local”

将该行注释即可让所有客户端访问:

# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
#        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>


四、启动和关闭phpMyAdmin服务
执行lampp命令,位于/opt/lampp目录下,附加start参数启动服务:
# /opt/lampp/lampp start  


服务启动后,就可以通过浏览器访问 http://IP地址。第一次访问会提示选择语种,XAMPP自带多语言支持,包括中文,phpMyAdmin在左下角,点击该按钮,就可以进入phpMyAdmin的管理界面了。
在界面中,查看权限列表,查看对象结构,会看到全部都是中文。
在“状态”-“所有状态变量”中,也可以看到所有状态变量及对应中文解释。
注意:XAMPP软件下载网站链接在SourceForge,可能被隔开墙外,建议将介质下载到电脑备用。
XAMPP的安全强度不够,若计划在生产环境中,需要参考广发文档修改设置,加强安全性。

如果要关闭XAMPP服务,则执行命令:

# /opt/lampp/lampp stop


如果要重启XAMPP服务,则执行命令:

# /opt/lampp/lampp restart  



五、配置phpmyadmin 376 
phpMyAdmin在开发模式使用没有问题,但如果要在生产环境中使用,还需要增加一些安全性问题。
Is XAMPP production ready?
XAMPP is not meant for production use but only for development environments. The way XAMPP is configured is to be open as possible to allow the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

Here a list of missing security in XAMPP:

The MySQL administrator (root) has no password.
The MySQL daemon is accessible via network.
ProFTPD uses the password "lampp" for user "daemon".
PhpMyAdmin is accessible via network.
Examples are accessible via network.

To fix most of the security weaknesses simply call the following command:

sudo /opt/lampp/lampp security

It starts a small security check and makes your XAMPP installation secure. For example this protects the XAMPP demo pages by a username ('lampp') and password combination.

说到日常使用,phpMyAdmin当前连接的MySQL数据库,并不是要管理的数据库。MySQL最大的缺点是,默认只能连接本地的MySQL数据库,且自带的MySQL数据库密码为空。
所以需要对phpMyAdmin进行一些修改:
1.先使用vi编辑器打开登录认证的配置文件(若是Windows环境可用记事本打开):
# vi /opt/lampp/phpmyadmin/libraries/auth/cookie.auth.lib.php
第212-217行有以下内容:


修改为:


加粗是是我们变动过的内容,修改完之后保存退出。


2.接下来修改phpMyAdmin首页:
# vi /opt/lampp/phpmyadmin/index.php


最顶部增加下列代码(加在第10行):
ini_set("error_reporting","E_ALL & ~E_NOTICE")
if($_POST["pma_servername"] != "" && $_POST["pma_mysqlport"]) != "" && $_POST["pma_username"] !=""){
setcookie("pma_servername",$_POST["pma_servername"]);
setcookie("pma_mysqlport",$_POST["pma_mysqlport"]);
setcookie("pma_username",$_POST["pma_username"]);
}  else {
setcookie("pma_mysqlport","");
}
修改完成后,保存退出。


3.最后修改默认配置:
# vi /opt/lampp/phpmyadmin/libraries/config.default.php
查找并分别修改下列选项值(双斜杠后为行号):
$cfg['blowfish_server'] = 'junsansi'; //line 87
$cfg['Servers'][$1]['host'] = $_COOKIE["pma_servername"]; //line 110
$cfg['Servers'][$i]['port'] = $_COOKIE["pma_mysqlport"]; //117
$cfg['Servers'][$i]['auth_type'] = 'cookie'; //186
$cfg['Servers'][$i]['user'] = $_COOKIE["pma_username"]; //208
$cfg['LoginCookieValidity'] = 14400; //676
$cfg['AllowArbitraryServer'] = true; //721
修改主配置文件:
# vi /opt/lampp/phpmyadmin/config.inc.php
根据实际情况,修改下列变量值,注意 $cfg['blowfish_secret'] 变量值必须与前面配置文件中指定的值相同:
$cfg['blowfish_secret'] = 'junsansi'; //line 6
$cfg['Server'][$1]['auth_type'] = 'cookie'; //line 19
保存退出,然后重新刷新index.php页面,就能看到登录的界面:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值