配置参数按照以下参数
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/ --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-zlib-dir --with-bz2 --with-curl --enable-exif --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --enable-ftp --with-freetype-dir=/usr/lib/ --enable-gd-native-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm
注:指定--prefix是必要的,以免默认安装后的文件不好找;如果用Mysql数据库,那么--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config是必要的;如果希望使用PDO访问数据库,那 --with-pdo-mysql=/usr/local/mysql是必要的;使用--enable-fpm是必要的,我试了下不带词选项,那样就就只能使用cgi方式,不好使。
其他选项可选,执行中,如果找不到相关文件或路径,需要单独再安装相关的库,一般的库在RHEL5.3的安装盘上都能搜到,试试吧。
安装成功后使用php-fpm命令无法启动php,提示/usr/local/php5/etc/php-fpm.conf找不到(如果上面没指定--prefix,那么这里提示的路径可能是另外一个),此时 将
/usr/local/php5/etc/php-fpm.conf.default 拷贝一份到 /usr/local/php5/etc/php-fpm.conf 即:
cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
make
make test
测试结果可能会有些错误,但是一般不影响使用
make install
期间可能有一部操作**test执行的特别慢,耐心等几分钟或者几十分钟就会过去的。
安装成功后,会有以下提示
Installing PHP CLI binary: /usr/local/php5/bin/
Installing PHP CLI man page: /usr/local/php5/php/man/man1/
Installing PHP FPM binary: /usr/local/php5/sbin/
Installing PHP FPM config: /usr/local/php5/etc/
Installing PHP FPM man page: /usr/local/php5/php/man/man8/
Installing PHP FPM status page: /usr/local/php5/php/fpm/
Installing PHP CGI binary: /usr/local/php5/bin/
Installing build environment: /usr/local/php5/lib/php/build/
Installing header files: /usr/local/php5/include/php/
Installing helper programs: /usr/local/php5/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php5/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php5/lib/php/
[PEAR] Archive_Tar - already installed: 1.3.7
[PEAR] Console_Getopt - already installed: 1.3.0
[PEAR] Structures_Graph- already installed: 1.0.4
[PEAR] XML_Util - already installed: 1.2.1
[PEAR] PEAR - already installed: 1.9.4
Wrote PEAR system config file at: /usr/local/php5/etc/pear.conf
You may want to add: /usr/local/php5/lib/php to your php.ini include_path
/home/vcread/tools/php-5.4.6/build/shtool install -c ext/phar/phar.phar /usr/local/php5/bin
ln -s -f /usr/local/php5/bin/phar.phar /usr/local/php5/bin/phar
Installing PDO headers: /usr/local/php5/include/php/ext/pdo/
这里写明了很多路径。当然更完整的获取方式是,通过执行平phpinfo:
写一个info.php文件 写入
<?php
phpinfo();
?>
然后执行php info.php 就会打印出已安装的配置,从这里可以获得php.ini的路径。拷贝一份。
在源代码文件夹下有php.ini-production或其他的,拷贝一份到/usr/local/php5/php.ini即可。
将php-fpm设置为服务启动
切换到php源文件目录cd php-5.4.6/sapi/fpm/
ls
config.m4 CREDITS fpm init.d.php-fpm init.d.php-fpm.in LICENSE Makefile.frag php-fpm php-fpm.8 php-fpm.8.in php-fpm.conf php-fpm.conf.in status.html status.html.in
cp init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
/etc/init.d/php-fpm start
/sbin/chkconfig --add php-fpm (添加到开机服务列表)
/sbin/chkconfig php-fpm on
php-fpm的启动、停止和重启:
/etc/init.d/php-fpm start
/etc/init.d/php-fpm stop
/etc/init.d/php-fpm reload
以上操作后可以按照service php-fpm start来进行。
注意事项:
如果mysql是通过rpm包安装的,即时安装了devel包,指定了configure选项到mysql头文件目录,仍然会提示找不到(Note that the MySQL client library is not bundled anymore!),此时只能通过卸载原有mysql,并通过源代码装mysql
./configure --prefix=/usr/local/mysql --enable-thread-safe-client
最好是这些参数都带着,避免默认安装