源码安装PHP的坑

来源:互联网 发布:安吉汽车物流知乎 编辑:程序博客网 时间:2024/06/02 03:35

昨天想尝试为PHP写一点小扩展,结果硬是写不上去。就自己从官网下了一个版本进行源码编译安装,中间遇见好多坑,总结记录下来。

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

sudo apt-get install libxml2-dev

2.configure: error: Cannot find OpenSSL’s evp.h or hmac.h

sudo apt-get install libssl-dev

3.configure: error: Please reinstall the BZip2 distribution

sudo apt-get install libbz2-dev

4.configure: error: mcrypt.h not found. Please reinstall libmcrypt.

sudo apt-get install libmcrypt-dev

5.configure: error: Please reinstall readline - I cannot find readline.

sudo apt-get install libreadline6-dev

6.Sorry, I cannot run apxs

安装apache服务后,是不会带Apxs,需要安装 apache2-dev。其命令是:
sudo apt-get install apache2-dev
安装完后查看安装的路径: whereis apxs2

如果在安装Mod_pythond的make过程出现这样到错误:fatal error: Python.h: No such file or directory,可以安装python2.7-dev(装的是V2.7)解决,命令为:
sudo apt-get install python2.7-dev
Apxs的默认位置:usr/bin/apxs,但在ubuntu11版本中已经是usr/bin/apxs2。

但是,由于路径不一样,还需要加一个软链接:
ln -s /usr/bin/apxs /usr/local/bin/apxs

以上就是我昨天安装PHP遇见的坑,然后PHP安装扩展可以参考Rango的博客:

  1. PHP安装C函数扩展
  2. PHP实现类扩展
  3. 用C/C++扩展你的PHP
0 0