ubuntu下源码安装PHP7

  ~引

  之前买的服务器到期了,想学点东西还要自己安装虚拟机烦的要死,正好看到有服务器搞活动就买了一个用来玩。其实也可以使用集成环境,不过集成环境有时候对拓展安装不友好,真实的生产也基本上很少有使用集成环境的

  Linux:Ubuntu18

  PHP :php-7.2.23

  首先官网下载php源码,最好是在官网下载,因为你从别的地方下载你也不知道他们对源码有没有进行加工

  1.解压 tar -xvf php-7.2.23.tar.bz2

  2.安装  ./configure --prefix=/usr/local/php --disable-fileinfo,最后报错了configure: error: libxml2 not found. Please check your libxml2 installation. 缺少配置,缺什么装什么就可以了。
还有个问题就是我服务器内存比较小所以要加 --disable-fileinfo,不然make的时候会报错,更多参数看自己喜好需求去配置。
  3.报错安装 apt-get install libxml2-dev   4.重新执行第二步操作,出现下面则表示检测通过 可以安装了
  +--------------------------------------------------------------------+
  | 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.
  5.make && make install  #这个过程有点久,看服务器配置
  6.安装成功检测是否可以用./bin/php /usr/local/php/bin/test.php (test文件是我自己写的一个php文件用来检测使用的)
  7.配置环境变量我用的ubuntu没有.bash_profile文件,所以使用.profile
  PATH=$PATH:$HOME/bin
  export PHTH
  alias php=/usr/local/php/bin/php

   8.是环境变量生效  source ~/.profile,检测php /usr/local/php/bin/test.php,结果输出。

  ok,安装完成。

  

  

猜你喜欢

转载自www.cnblogs.com/caoql/p/11649797.html
今日推荐