最近由于需要用到phpMyAdmin来管理服务器上的mysql数据库,所以今天就学习了下如何安装phpMyAdmin,顺便也记录下来以备后查。
一、软件安装包
1.httpd-2.2.6.tar.gz
2.php-5.2.5.tar.gz
3.phpMyAdmin-2.11.5.1-all-languages.tar.gz
4.php-mysqlnd-5.0.1-beta.tar.gz
二、安装apache的httpd
#tar xf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure --prefix=/usr/local/apache2 --enable-module=so
#make
#make install
三、安装php5
#tar xf php-mysqlnd-5.0.1-beta.tar.gz
#tar xf php-5.2.5.tar.gz
#cd php-5.2.5
#rm -f -R ext/mysqli
#cp -R ../php-mysqlnd-5.0.1-beta/php5/ext/mysqli ./ext/
#./buildconf --force
#./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-mysqli --enable-mysqlnd --with-mbstring --enable-mbstring=all
#make
#make install
#cp php.ini-dist /usr/local/lib/php.ini
四、安装phpMyAdmin(假设安装目录在:/webapp/phpMyAdmin)
#tar xf phpMyAdmin-2.11.5.1-all-languages.tar.gz
#mv phpMyAdmin-2.11.5.1-all-languages /webapp/phpMyAdmin
五、配置apache的httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
1)将DocumentRoot和Directory的目录改为:/webapp/phpMyAdmin
2)在DirectoryIndex中添加index.php
3)添加php的扩展类型:
AddType application/x-httpd-php .php .phtml .php3 .inc
AddType application/x-httpd-php-source .phps
六、配置phpMyAdmin
#cd /webapp/phpMyAdmin
#cp config.sample.inc.php config.inc.php
#vi config.inc.php
对如下的字段进行配置即可,没有的可以自己添加:
$cfg['Servers'][$i]['auth_type'] = 'config'; // 认证模式,可以有cookie、http和config
$cfg['blowfish_secret'] = 'mabiqiang'; // 使用cookie方式认证的密码短语
$cfg['Servers'][$i]['host'] = '127.0.0.1'; // 设置你的数据库服务器的访问IP
$cfg['Servers'][$i]['user'] = 'root'; // config认证模式时的访问用户名称
$cfg['Servers'][$i]['password'] = 'root'; // config认证模式时的访问密码
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // 连接方式,tcp(默认)或socket
$cfg['Servers'][$i]['extension'] = 'mysqli'; // MYSQL扩展,可以为mysql和mysqli(推荐mysql4.1.0以上版本)
$cfg['Servers'][$i]['only_db'] = array('db1','db2'); // 只显示指定的数据库,字符串或数组
以上是给出了phpMyAdmin的基本配置信息,具体的还需要根据个人的情况做适当的调整。另外,对于php5的安装,我是使用了mysql官方提供的php-mysqlnd-5.0.1-beta.tar.gz,而没有使用mysql-dev。前者是mysql官方最新推荐的php对mysql的访问驱动,相比以前的,官方的解说如下:
Q: Is mysqlnd a new PHP extension?
No, the new MySQL driver for PHP is not a new PHP extension. The driver is a replacement for libmysql on the internal C level of the PHP extension ext/mysqli.
You can continue to compile the ext/mysqli extension with libmysql like ever since. We will not remove this functionality. Alternatively you can compile ext/mysqli with mysqlnd. We suggest that you try it, because mysqlnd is easier to compile and we found it to be faster than libmysql.
Q: Does it work with any MySQL Server before 4.1?
The MySQL native driver for PHP requires PHP 5 or PHP 6.
You can use it to connect to the MySQL Server 4.1 or newer.
Q: Can other PHP extensions use it?
Yes, they can, if they want to. The source code of the new driver is the ext/mysqli/mysqlnd directory of the download files. Extension writes will find that mysqlnd mimics the API of libmysql respectively the MySQL C API.