ubuntu13.10源碼安裝php5.5

1.下載PHP軟件 php


2.tar解壓

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


3.下載libxml2 http://xmlsoft.org
    tar解壓
    ./configure
    make

    make install 算法


4.若是安裝過libxml2,能夠跳過3,安裝libxml2-dev

    sudo apt-get install libxml2-dev sql


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

    sudo apt-get install Bison apache


6.安裝加密算法擴展庫libmcrypt
    下載libmcrypt2.5.8.tar.gz
    tar -zxvf libmcrypt2.5.8.tar.gz
    cd libmcrypt2.5.8
    ./configure

    make & make install vim


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 app


9.安裝PHP依賴庫freetype
    下載freetype
    tar
    cd
    ./configure --prefix=/usr/local/freetype
    make 

    make install socket


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();     ?>     在瀏覽器中瀏覽網頁,顯示則成功
相關文章
相關標籤/搜索