经常要用到linux环境下自己编译安装php,configure参数繁多,有时候不加注意使用的时候又要重新编译php,所以将常用的configure命令整理如下。
第一步,安装依赖包:
yum -y install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel libaio
实际应该中可能还需要安装mcrypt扩展(典型错误:phpmyadmin报错,无法载入mcrypt扩展)。
要安装mcrypt扩展,可以使用命令:
yum install libmcrypt-devel
然后再使用命令:
yum install php-mcrypt
这样就成功安装mcrypt扩展了。
第二步,安装php:
cd /tmpwget http://cn2.php.net/get/php-5.5.10.tar.gz/from/cn2.php.net/mirrortar -zxvf mirrorcd ./php-5.5.10
然后执行命令:
./configure \--prefix=/usr/local/php5 \--with-config-file-path=/usr/local/php5/etc \--with-bz2 \--with-curl \--enable-ftp \--enable-sockets \--disable-ipv6 \--with-gd \--with-jpeg-dir=/usr/local \--with-png-dir=/usr/local \--with-freetype-dir=/usr/local \--enable-gd-native-ttf \--with-iconv-dir=/usr/local \--enable-mbstring \--enable-calendar \--with-gettext \--with-libxml-dir=/usr/local \--with-zlib \--with-pdo-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-mysql=mysqlnd \--enable-dom \--enable-xml \--with-libdir=lib64 \--enable-pdo \--enable-fpm \--enable-mcrypt
编译过程有可能报如下错误:
checking for known struct flock definition… configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no
解决方法是:
yum groupins+本文来源gao!%daima.com搞$代*!码9网(
搞gaodaima代码tall "Development tools"
最后分别执行命令:
makemake install
以上就介绍了linux源码编译php5.4以上自带php-fpm的configure参数和依赖包,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。