Centos下编译安装php5.4

Centos 下编译安装php5.4.0,编译安装php-5.4.0 ,php5.4.0 Zend Guard Loader暂时不支持,等待zend官方更新。

1.下载

wget wget http://cn.php.net/distributions/php-5.4.0.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"
wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.5-9.tar.gz
wget http://pecl.php.net/get/imagick-3.0.1.tgz2.编译安装PHP 5.4.0所需的支持库
wget http://pecl.php.net/get/memcache-3.0.7.tgz

tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install
cd ../

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

3.编译mysql5.5.21
wget http://mysql.stu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz

wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
tar xvzf cmake-2.8.7.tar.gz
./configure
make
make install

编译安装mysql
tar xvzf mysql-5.5.21.tar.gz
cd mysql5.5.21
rm CMakeCache.txt
cmake .
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.21/
-DMYSQL_DATADIR=/usr/local/mysql5.5.21/data
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/usr/local/mysql5.5.21/data/mysql.sock
-DMYSQL_USER=mysql
-DWITH_DEBUG=0

make && make install 4.编译php

安装依赖包
yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel net-snmp-devel

tar xvzf php-5.4.0.tar.gz
cd php-5.4.0
./configure --prefix=/web/server/php --with-config-file-path=/web/server/php/etc --with-mysql --with-mysqli --with-pdo-mysql --with-iconv-dir=/usr/local --enable-fpm --disable-phar --with-fpm-user=www-data --with-fpm-group=www-data --with-pcre-regex --with-zlib --with-bz2 --enable-calendar --with-curl --enable-dba --with-libxml-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-mhash --enable-mbstring --with-mcrypt --enable-pcntl --enable-xml --disable-rpath --enable-shmop --enable-sockets --enable-zip --enable-bcmath --with-snmp --disable-ipv6

make ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp php.ini-production /usr/local/php5.4.0/etc/php.ini5.编译安装PHP5扩展模块

如果运行/web/server/php/bin/phpize,出现如下提示,则要安装m4 autoconf
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
yum install autoconf
yum install m4

tar zxvf memcache-3.0.7.tgz
cd memcache-3.0.7/
/web/server/php/bin/phpize
./configure --with-php-config=/web/server/php/bin/php-config
make
make install
cd ../

/*暂时没有编译成功*/
tar xvzf memcached-1.0.2.tgz
cd memcached-1.0.2
/web/server/php/bin/phpize
./configure --with-php-config=/web/server/php/bin/php-config
make
make install
cd ../

/*没有编译*/
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

/*没有编译*/
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php5.4.0/bin/phpize
./configure --with-php-config=/usr/local/php5.4.0/bin/php-config
make
make install
cd ../6.修改配置

vi /web/server/php/etc/php.ini

最后增加:
;change for hugwww
extension_dir = /usr/local/php5.4.0/lib/php/extensions/no-debug-non-zts-20090626/

extension = "memcache.so"
extension = "memcached.so"
extension = "imagick.so"

修改为:
cgi.fix_pathinfo=0
open_basedir = /tmp:/www/web
expose_php = Off
allow_url_fopen = Off
disable_functions =phpinfo,passthru,ini_restore,eval完成!


本文固定链接: http://blog.wwllcchf.com/?p=36 | 吴文龙的个人博客

作者:wuwenlong 于2013年03月03日发表 &
Centos下编译安装php5.4 | 吴文龙的个人博客
【上一篇】
【下一篇】

Centos下编译安装php5.4:目前有1 条留言

  1. 沙发
    紫衣若兰:

    –prefix=/usr/local/php5 //指定 php 安装目录
    –with-apxs2=/usr/local/apache2/bin/apxs //整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块
    –with-config-file-path=/usr/local/php5/etc //指定php.ini位置
    –with-MySQL=/usr/local/mysql //mysql安装目录,对mysql的支持
    –with-mysqli=/usr/local/mysql/bin/mysql_config //mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。
    –enable-safe-mode //打开安全模式
    –enable-ftp // 打开ftp的支持
    –enable-zip // 打开对zip的支持
    –with-bz2 //打开对bz2文件的支持
    –with-jpeg-dir //打开对jpeg图片的支持
    –with-png-dir //打开对png图片的支持
    –with-freetype-dir //打开对freetype字体库的支持
    –without-iconv //关闭iconv函数,种字符集间的转换
    –with-libXML-dir //打开libxml2库的支持
    –with-XMLrpc //打开xml-rpc的c语言
    –with-zlib-dir //打开zlib库的支持
    –with-gd //打开gd库的支持
    –enable-gd-native-ttf //支持TrueType字符串函数库
    –with-curl //打开curl浏览工具的支持
    –with-curlwrappers //运用curl工具打开url流
    –with-ttf //打开freetype1.*的支持,可以不加了
    –with-xsl //打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件
    –with-gettext //打开gnu 的gettext 支持,编码库用到
    –with-pear //打开pear命令的支持,PHP扩展用的
    –enable-calendar //打开日历扩展功能
    –enable-mbstring //多字节,字符串的支持
    –enable-bcmath //打开图片大小调整,用到zabbix监控的时候用到了这个模块
    –enable-sockets //打开 sockets 支持
    –enable-exif //图片的元数据支持
    –enable-magic-quotes //魔术引用的支持
    –disable-rpath //关闭额外的运行库文件
    –disable-debug //关闭调试模式
    –with-mime-magic=/usr/share/file/magic.mime //魔术头文件位置
    CGI方式安装才用的参数
    –enable-fpm //打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序
    –enable-fastCGI //支持fastcgi方式启动PHP
    –enable-force-CGI-redirect //重定向方式启动PHP
    –with-ncurses //支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库
    –enable-pcntl //freeTDS需要用到的,可能是链接mssql 才用到
    mhash和mcrypt算法的扩展
    –with-mcrypt //算法
    –with-mhash //算法
    以上函数库需要安装
    –with-gmp //应该是支持一种规范
    –enable-inline-optimization //优化线程
    –with-openssl //openssl的支持,加密传输时用到的
    –enable-dbase //建立DBA 作为共享模块
    –with-pcre-dir=/usr/local/bin/pcre-config //perl的正则库案安装位置
    –disable-dmalloc
    –with-gdbm //dba的gdbm支持
    –enable-sigchild
    –enable-sysvsem
    –enable-sysvshm
    –enable-zend-multibyte // 支持zend的多字节
    –enable-mbregex
    –enable-wddx
    –enable-shmop
    –enable-soap

    2013-08-20 下午 3:08