centos 单独安装PHP的mysql和mysqli扩展

2013年11月22日 11:25:41

Linux centos 6.3 最小化安装

mysql 5.5

php 5.4

安装PHP时只是 ./configure --prefix=/****

并没有其它的设置,随后又去安装的其它扩展(纯属瞎折腾,学习怎么用Linux)

在安装mysql和mysqli的扩展时的命令还不一样

生成mysql.so

1 cd php-5.4.22/include/ext #源码解压包的扩展目录
2 cd mysql #进入mysql扩展
3 /usr/local/lamp/php54/bin/phpize
4 ./configure --with-php-config=/usr/local/lamp/php54/bin/php-config --with-mysql=/usr/local/lamp/mysql
5 make && make install

生成msyqli.so

和生成msyql.so的步骤中前三步是一模一样的,不同的是第四步:

1 ./configure --with-php-config=/usr/local/lamp/php54/bin/php-config --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config

否则会报警告:

You will need re2c 0.13.4 or later if you want to regenerate PHP parsers

然后再 make && make install 就可以生成mysqli.so了

但是,不是说PHP5.4已经默认有mysqlnd了么,为什么这里还得指定mysql的安装目录才能生成mysql扩展?

1 ./configure --help
2 
3  --with-mysql=DIR      Include MySQL support.  DIR is the MySQL base
4                           directory, if no DIR is passed or the value is
5                           mysqlnd the MySQL native driver will be used
6 
7  --with-mysqli=FILE    Include MySQLi support.  FILE is the path
8                           to mysql_config.  If no value or mysqlnd is passed
9                           as FILE, the MySQL native driver will be used

配置命令:

1 ./configure --prefix=**** --enable-mysqlnd --with-mysql --with-mysqli

如果之前编译(make)失败,记得用make clean 或者 make distclean 清除之前编译的缓存文件,然后再重新make && make install

----------------------------

安装 re2c ,语法分析器,编译PHP时用到

1 wget http://jaist.dl.sourceforge.net/project/re2c/re2c/0.13.6/re2c-0.13.6.tar.gz

------------------------------------

PHP的配置文件在解压后的源码包里

如果安装的时候指定了配置文件的安装路径,安装程序就会将配置文件.....(稍后再叙)

1 --with-config-file-path=PATH
2                           Set the path in which to look for php.ini [PREFIX/lib]

推荐一个PHP框架: SummerPHP