当前位置: 代码迷 >> PHP >> fedora16停PHP5.4编译安装笔记
  详细解决方案

fedora16停PHP5.4编译安装笔记

热度:12   发布时间:2016-04-29 00:48:22.0
fedora16下PHP5.4编译安装笔记
今天重装了下PHP,顺便尝鲜一下5.4,期间涉及到的多数软件我都是选择的最新稳定版。这里要注意的就是PHP的一个编译参数:--with-gd=shared ,这里切不可把shared替换为gd2的安装目录/usr/local/gd2,不然会无法编译通过,网上查了下好像是PHP5.3-5.4的一个bug。

yum install -y gcc g-c++ gcc-c++ libtool openssl-devel pam-devel python-devel libxml2-devel

sourcepath="/opt/source/"

cd {$sourcepath}
wget http://fossies.org/unix/misc/zlib-1.2.6.tar.gz
mkdir /usr/local/zlib
tar zxvf zlib-1.2.6.tar.gz
cd zlib-1.2.6
./configure --prefix=/usr/local/zlib
make && make install
echo "/usr/local/zlib/lib" >> /etc/ld.so.conf
ldconfig
chcon -t textrel_shlib_t /usr/local/zlib/lib/libz.so*

cd {$sourcepath}
wget http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz
tar zxvf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
./configure --prefix=/usr/local/libxml2  --with-python
make
make install
LD_LIBRARY_PATH=/usr/local/lib
LD_LIBRARY_PATH=/usr/local/libxml2/lib
LD_LIBRARY_PATH=/usr/lib/python2.7/site-packages
echo "/usr/local/libxml2/lib" >> /etc/ld.so.conf
echo "/usr/lib/python2.7/site-packages" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://xmlsoft.org/sources/libxslt-1.1.26.tar.gz
mkdir /usr/local/libxslt
tar zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make
make install
echo "/usr/local/libxslt/lib" >> /etc/ld.so.conf
echo "/usr/local/libxslt/lib/python2.7/site-packages" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://vps.googlecode.com/files/libiconv-1.13.1.tar.gz
mkdir /usr/local/libiconv
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install
echo "/usr/local/libiconv/lib" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://vps.googlecode.com/files/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
echo "/usr/local/lib" >> /etc/ld.so.conf
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
ldconfig

cd {$sourcepath}
wget http://vps.googlecode.com/files/libmcrypt-2.5.8.tar.gz
mkdir /usr/local/libmcrypt
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/libltdl
./configure  --enable-ltdl-install
make
make install
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
cd {$sourcepath}
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
ln -s /usr/local/libmcrypt/lib/libmcrypt.la         /usr/lib/libmcrypt.la
ln -s /usr/local/libmcrypt/lib/libmcrypt.so         /usr/lib/libmcrypt.so
ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4       /usr/lib/libmcrypt.so.4
ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4.4.8   /usr/lib/libmcrypt.so.4.4.8
cp /usr/local/libmcrypt/bin/libmcrypt-config /usr/bin/libmcrypt-config
cp /usr/local/libmcrypt/lib/libmcrypt.* /usr/lib
echo "/usr/local/libmcrypt/lib" >>  /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://vps.googlecode.com/files/mcrypt-2.6.8.tar.gz
mkdir /usr/local/mcrypt
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/lib
./configure --prefix=/usr/local/mcrypt --with-libmcrypt-prefix=/usr/local/libmcrypt --with-libiconv-prefix=/usr/local/libiconv
make && make install

cd {$sourcepath}
wget http://curl.cs.pu.edu.tw/download/curl-7.25.0.tar.gz
tar zxvf curl-7.25.0.tar.gz
cd curl-7.25.0
./configure
make && make install
ldconfig

cd {$sourcepath}
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.9.tar.gz
mkdir /usr/local/freetype2
tar zxvf freetype-2.4.9.tar.gz
cd freetype-2.4.9
./configure --prefix=/usr/local/freetype2
make && make install
echo "/usr/local/freetype2/lib"  >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://freedesktop.org/software/fontconfig/release/fontconfig-2.9.0.tar.gz
mkdir /usr/local/fontconfig
tar zxvf fontconfig-2.9.0.tar.gz
cd fontconfig-2.9.0
export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
cp -r /usr/local/libxml2/include/libxml2/libxml/ /usr/include/
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype2/bin/freetype-config
make && make install
echo "/usr/local/fontconfig/lib" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz
mkdir /usr/local/libpng2
tar zxvf libpng-1.5.9.tar.gz
cd libpng-1.5.9/
export LDFLAGS=-L/usr/local/zlib/lib
export CFLAGS=-I/usr/local/zlib/include
./configure --prefix=/usr/local/libpng2
make && make install
echo "/usr/local/libpng2/lib" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://www.ijg.org/files/jpegsrc.v8d.tar.gz
mkdir /usr/local/jpeg8
mkdir /usr/local/jpeg8/include
mkdir /usr/local/jpeg8/lib
mkdir /usr/local/jpeg8/bin
mkdir /usr/local/jpeg8/man/man1/ -p
tar zxvf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure --prefix=/usr/local/jpeg8 --enable-shared --enable-static
make && make install
echo "/usr/local/jpeg8/lib" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
mkdir /usr/local/gd2
tar zxvf gd-2.0.35.tar.gz
cd gd/2.0.35
cp /usr/local/libpng2/include/pngconf.h {$sourcepath}gd/2.0.35/
./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib --with-jpeg=/usr/local/jpeg8 --with-freetype=/usr/local/freetype2 --with-xml=/usr/local/libxml2 --with-png=/usr/local/libpng2 --with-fontconfig=/usr/local/fontconfig --with-slt=/usr/local/libxslt
make && make install
echo "/usr/local/gd2/lib" >> /etc/ld.so.conf
ldconfig

cd {$sourcepath}
wget http://fossies.org/linux/misc/giflib-4.1.6.tar.gz
tar zxvf giflib-4.1.6.tar.gz
cd giflib-4.1.6
./configure
make && make install

cd {$sourcepath}
wget http://www.php.net/get/php-5.4.0.tar.gz/from/cn2.php.net/mirror
tar zxf php-5.4.0.tar.gz
cd php-5.4.0
./configure  --prefix=/usr/local/php --with-config-file-path=/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=shared --with-jpeg-dir=/usr/local/jpeg8  --with-png-dir=/usr/local/libpng2 --enable-gd-native-ttf --with-zlib-dir=/usr/local/zlib --with-freetype-dir=/usr/local/freetype2 --enable-zip --with-libxml-dir=/usr/local/libxml2 --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-pdo-pgsql=/usr/local/pgsql --with-curl --with-mcrypt=/usr/local/libmcrypt --enable-mbstring=all --with-mhash --enable-soap --enable-sockets --with-pear --enable-gd-native-ttf --enable-ftp --disable-ipv6 --with-iconv
make
make test
make install


修改/usr/local/apache2/conf/httpd.conf

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
下面添加
    PHPIniDir "/etc"
    AddType application/x-httpd-php .php

重启apache,搞定!