ubuntu 编译 php5.5,在Ubuntu下编译和安装PHP 5.2.8

在Ubuntu下开始编译和安装PHP之前,首先要安装一下软件包

1、flex

sudo apt-get install flex

2、apache2-threaded-dev

sudo apt-get install apache2-threaded-dev

安装之后,可以在一下位置找到安装的内容

如故是apache2

/usr/bin/apxs2

如果是apache1

/usr/bin/apxs

3、libxml2-dev

sudo apt-get install libxml2-dev

在安装好以上软件之后,需要修改一下httpd.conf

在httpd.conf中增加点虚假的内容

例如:

# Dummy LoadModule directive to aid module installations

# LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so

因为如果httpd.conf内容为空的话

安装PHP会出错。

开始编译和安装PHP

1、解压

$ tar zxvf php-5.2.8.tar.gz

2、查看可以用的编译参数

$ ./configure -help

3、现来个就基本的安装,除了支持apache2以外,其他的都不管。以后使用过程中遇到其他问题,再修改编译参数,逐个处理。

其中

--prefix用来指定安装目录

--with-apxs2用来指定apxs2的位置。

./configure --prefix=/usr/local/php --with-apxs2=/usr/bin/apxs2

2、编译

make

3、编译测试

make test

3、安装

sudo make install

修改httpd.conf

增加以下内容

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

在/var/www/中添加index.php

echo phpinfo();

?>

重新启动apache

sudo apache2ctl -k restart

用浏览器访问127.0.0.1/index.php0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
项目中要用到zend Optimizer,但是目前只支持php5.2Ubuntu默认安装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、付费专栏及课程。

余额充值