ubuntu 编译 php5.5,ubuntu15.04编译安装php5.3和5.2

在Ubuntu Mate上,由于预装的PHP版本过高导致某些程序(如ECShop)运行错误。本文档详细记录了如何卸载PHP5.6并编译安装PHP5.3的过程,包括遇到的依赖问题如libxml2、libbz2、libcurl、libjpeg、libfreetype、libmcrypt、libmysqlclient、libtidy的解决方法。通过安装相应的-dev包,创建软链接等手段解决了配置错误,最终成功安装PHP5.3并调整php.ini路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我安装的ubuntu  mate 桌面64位

源里的php版本太高,像ecshop这种的程序跑起来老报错,调起来费劲,所以装个5.3.

先卸载php5.6:

sudo apt-get --purge remove php5

sudo apt-get autoremove php5

用 dpkg -l | grep php 和dpkg -l | grep php5 检查,如无返回即干净卸载

下面说一下编译安装php5.3,下载地址:http://php.net/releases/

自己找一个版本,我安装的是5.3.29,以下是具体过程:

下载并解压,执行:

./configure --prefix=/usr/local/php --with-mcrypt --with-gettext --with-mysql --with-gd --with-jpeg-dir --with-png-dir --with-curl --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-sockets --with-pdo-mysql --enable-fpm --with-zlib --enable-zip --with-bz2 --enable-bcmath --with-tidy --with-fpm-user=daemon --with-fpm-group=daemon

报错:error: xml2-config not found. Please check your libxml2 installation.

安装: libxml2-dev

报错:configure: error: Please reinstall the BZip2 distribution

安装: libbzip2-dev

报错:configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/

安装:libcurl4-gnutls-dev

报错:configure: error: jpeglib.h not found.

安装:libjpeg-dev

报错:configure: error: freetype.h not found.

解决办法:

安装:libfreetype6-dev

报错:configure: error: freetype.h not found.

但是libfreetype6-dev和libfreetype6已经安装了,需要做个软链接

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

报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

安装:libmcrypt-dev

报错:configure: error: Cannot find MySQL header files under yes.

Note that the MySQL client library is not bundled anymore!

安装:libmysql++-dev

报错:configure: error: Cannot find libtidy

安装:libtidy-dev

没问题的话画出现:

+--------------------------------------------------------------------+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE.  By continuing this installation |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+--------------------------------------------------------------------+

Thank you for using PHP.

然后:make

可以先make test测试一下,如果有问题会出现:

You may have found a problem in PHP.

This report can be automatically sent to the PHP QA team at

http://qa.php.net/reports and http://news.php.net/php.qa.reports

This gives us a better understanding of PHP's behavior.

If you don't want to send the report immediately you can choose

option"s" to save it.  You can then email it to qa-reports@lists.php.net later.

Do you want to send this report now? [Yns]:

我的出现了这个问题,不过没什么影响

最后sudo make install

安装后会出现:

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf

You may want to add: /usr/local/php/lib/php to your php.ini include_path

/home/xxx/下载/php-5.3.29/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin

ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar

Installing PDO headers:          /usr/local/php/include/php/ext/pdo/

安装位置是/usr/local/php,所以要改一下/etc/php5/apache2/php.ini,添加include_path ="/usr/local/php/lib/php"

把原来的/usr/bin/php删掉,或者改名:sudo mv /usr/bin/php /usr/bin/php.bak

把编译出来的php5.3做个软链接:sudo ln -s /usr/local/php/bin/php /usr/bin/php

ecshop说好的支持php5.3和5.2,但是安装了5.2还是报错,再下php5.2.10,重新编译,方法类似,多的报错:

configure: error: libjpeg.(a|so) not found.

sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so.8 /usr/lib/libjpeg.so

configure: error: libpng.(a|so) not found.

sudo ln -s /usr/lib/i386-linux-gnu/libpng12.so.0 /usr/lib/libpng.so

configure: error: Cannot find libmysqlclient under /usr.

sudo ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 /usr/lib/libmysqlclient.so

项目中要用到zend Optimizer,但是目前只支持php5.2Ubuntu默认安装php版本为5.3,找了好多 方法,终于借助下面这篇文章的方法成功的安装5.25.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、付费专栏及课程。

余额充值