2552

ubuntu下编译安装php

乐果   发表于   2014 年 11 月 25 日 标签:ubuntuPHP

先安装必须的依赖库:

sudo apt-get install autoconf
sudo apt-get install libxml2-dev
sudo apt-get install bzip2
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libxpm-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libt1-dev
sudo apt-get install libmcrypt-dev
sudo apt-get install libmysql++-dev
sudo apt-get install libxslt1-dev 
sudo apt-get install libbz2-dev

开始编译安装:

sudo ./configure \
--prefix=/data/service/php53 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/data/service/php/etc \
--with-zlib \
--with-curl \
--with-curlwrappers \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-freetype-dir \
--with-zlib-dir \
--enable-shared \
--enable-fpm \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap 

##...过程省略

sudo make && sudo make install

ubuntu可能需要的步骤—软链接库文件:

cd /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.a .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4 .
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0 .

需要注意的

有可能因为系统缺少libiconv依赖库libiconv依赖库的路径不对,导致在make或make install步骤中报错。 此时,因检查系统中是否存在libiconv.so等动态库,

    find /usr -name libiconv.so

确定缺少该依赖库时,则下载安装。例如下载了libiconv-1.13.1版本时,安装步骤如下:

cd libiconv-1.13.1
./configure --prefix=/usr/local/lib/libiconv-1.13.1
sudo make
sudo make install

最后重新编译安装php,编译安装前先清除下:

    sudo make clean

在configure参数中加入iconv依赖库的路径

    --with-iconv=/usr/local/lib/libiconv-1.13.1

可能容易出现的报错:

configure: error: freetype.h not found.

freetype明明是使用apt-get安装了的。也可以查询到这个文件 但是就是不行

root@ubuntu:/c2ms/packages/php-5.3.28# cat configure |grep freetype.h      if test -f "$i/include/freetype2/freetype/freetype.h"; then
      { echo "configure: error: freetype.h not found." 1>&2; exit 1; }
      if test -f "$i/include/freetype2/freetype/freetype.h"; then
      { echo "configure: error: freetype.h not found." 1>&2; exit 1; }

结果我按照这个路径查找,果然没这个文件 ubuntu安装的目录文件只是这个:

include/freetype2/freetype.h 

所以

ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype

下次记得cat 不要太相信源码了

乐果   发表于   2014 年 11 月 25 日 标签:ubuntuPHP

0

文章评论