ubuntu13.10源码安装php5.5

1.下载PHP软件


2.tar解压

    tar -zxvf /home/sniper/Downloads/php-5.5.10.tar.gz


3.下载libxml2 http://xmlsoft.org
    tar解压
    ./configure
    make

    make install


4.如果安装过libxml2,可以跳过3,安装libxml2-dev

    sudo apt-get install libxml2-dev


5.安装PHP语法分析器re2c,Bison
    sudo apt-get install re2c

    sudo apt-get install Bison


6.安装加密算法扩展库libmcrypt
    下载libmcrypt2.5.8.tar.gz
    tar -zxvf libmcrypt2.5.8.tar.gz
    cd libmcrypt2.5.8
    ./configure

    make & make install


7.安装PHP依赖库zlib
    wget http://zlib.net/zlib-1.5.8.tar.gz
    tar解压到/usr/local/zlib
    进入zlib
    ./configure --prefix=/usr/local/zlib
    make

    make install


8.安装PHP依赖库libpng
    下载libpng
    tar 解压
    cd libpng文件夹
    ./configure --prefix=/usr/local/libpng
    make
    make install
    安装libpng-dev

    sudo apt-get install libpng-dev


9.安装PHP依赖库freetype
    下载freetype
    tar
    cd
    ./configure --prefix=/usr/local/freetype
    make 

    make install


10.安装PHP依赖库jpegsrc
    下载jpegsrc.v8c.tar.gz
    tar解压
    cd jpegsrc目录
    mkdir /usr/local/libjpeg
    mkdir /usr/local/libjpeg/include
    mkdir /usr/local/libjpeg/bin
    mkdir /usr/local/libjpeg/lib
    mkdir /usr/local/libjpeg/man
    mkdir /usr/local/libjpeg/man/man1
    也可以 
    mkdir -p /usr/local/libjpeg/man/man1
    ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
    一定要带上--enable-shared 生成共享库
    make

    make install


11.安装fontconfig
    下载fontconfig
    tar解压
    进入fontconfig目录
    ./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config
    make

    make install


12.安装GD库
    下载gd库
    tar解压
    进入gd目录
    ./configure --prefix=/usr/local/gd --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng --with-jpeg=/usr/local/libjpeg --with-fontconfig=/usr/local/fontconfig 
    如果出现如下信息,表示成功:
    ** Configuration summary for gd 2.0.34:


    Support for PNG library:       yes
    Support for JPEG library:       yes
    Support for Freetype 2.x library: yes
    Support for Fontconfig library: yes
    Support for Xpm library:       no
    Support for pthreads:          yes
    
    make
    如果make时出现如下错误:
    make[2]: *** [gd_png.lo] Error 1
    make[2]: Leaving directory `/tmp/gd-2.0.26gif'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/tmp/gd-2.0.26gif'
    make: *** [all] Error 2
    需要复制/usr/local/libpng/include/目录下两个文件,
    cp /usr/local/libpng/include/pngconf.h /home/sniper/Downloads/gd-2.0.33
    cp /usr/local/libpng/include/png.h /home/sniper/Downloads/gd-2.0.33
    cp /usr/local/libpng/include/pnglibconf.h /home/sniper/Downloads/gd-2.0.33
    再进行编译,可成功

    make install    


13.安装libiconv
    下载 tar cd 
    ./configure --prefix=/usr/local/libiconv
    如果出现如下错误:
    ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
     _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
     ^
    make[2]: *** [progname.o] Error 1
    make[2]: Leaving directory `/home/sniper/Downloads/libiconv-1.14/srclib'
    make[1]: *** [all] Error 2
    make[1]: Leaving directory `/home/sniper/Downloads/libiconv-1.14/srclib'
    make: *** [all] Error 2
    暂时未解决!
    

    make make install


14.进入php5.5.10文件夹

    cd php5.5.10


15.编译php
    ./configure 
    --prefix=/usr/local/php 
    --with-apxs2=/usr/local/apache/apxs 
    --with-mysql=/usr/local/mysql
    --with-gd=/usr/local/gd
    --with-ttf //激活freetype1.x的支持
    --with-freetype-dir=/usr/local/freetype //freetype2.x
    --with-jpeg-dir=/usr/local/libjpeg
    --with-png-dir=/usr/local/libpng
    --with-zlib-dir=/usr/local/zlib
    --enable-mbstring //激活mbstring模块
    --enable-xml // 支持XML
    --enable-sockets //支持套接字


16.生成可执行文件

    make


17.安装

    make install


18.打开Apache配置文件
    cd /usr/local/apache/conf
    vim httpd.conf
    找到AddType,在后边加上

    AddType application/x-httpd-php .php


19.复制php.ini

    cp /home/sniper/Downloads/php/php.ini-development /usr/local/php/lib/php.ini


20.在/usr/local/apache/htdocs/添加测试文件test.php
    <?php
        echo phpinfo();
    ?>
    在浏览器中浏览网页,显示则成功

你可能感兴趣的:(ubuntu13.10源码安装php5.5)