ubuntu13.10源码安装php5.5

本文详细介绍了从下载并解压PHP软件到安装所有依赖库的全过程,包括libxml2、libmcrypt、zlib、libpng、freetype、jpeg、fontconfig、GD库、libiconv等,并最终完成PHP的编译与安装。

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(); 
    ?> 
    在浏览器中浏览网页,显示则成功 

项目中要用到zend Optimizer,但是目前只支持php5.2,Ubuntu默认安装php版本为5.3,找了好多 方法,终于借助下面这篇文章的方法成功的安装5.2及5.3两个版本的php Although Drupals 7+ run smoothly on PHP 5.3, Drupal 6 still feels much better with PHP 5.2. Even though D6 core is compatible with PHP 5.3 for quite some time now, a lot of contributes modules still get nasty hiccup when asked to run on the newer version. Therefore developing for both D7 and D6 at the same time becomes much less painful when running both versions of PHP in parallel. One way of doing it is using mod_php5 Apache module to serve PHP 5.3 applications, while running PHP 5.2 applications using fastcgi module. Under Ubuntu 12.04 this can be achieved by installing PHP 5.3 from the repositories and manually compiling and installing PHP 5.2 afterwards. Installing PHP 5.3 from repositories is fairly easy process, which you most probably already have under your belt, so let's just say that it looks more or less like this: sudo apt-get install php5 php5-common php5-cli php5-dev php5-mysql phpmyadmin php5-pgsql phppgadmin php5-gd php5-mcrypt php5-curl php-pear libapache2-mod-php5 php5-xdebug php5-codesniffer What is much more interesting though, and what this post will focus on, is how to add PHP 5.2 to the whole picture and make both those versions work nicely together. Please note that this tutorial is for Apache's name- based virtual hosts, and essentially leaves PHP 5.3 enabled globally while allowing to use PHP 5.2 on specific, selected virtual hosts only.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值