首页 > 开发 > Php > 正文

在openSUSE42.1下编译安装PHP7 的方法

2020-02-18 23:00:02
字体:
来源:转载
供稿:网友

首先推荐一篇文章PHP 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog。

里面说到是否会去使用PHP7,就个人而言,我是毫不犹豫地使用的,但是生产环境就不是我说了算,所以只能自己在自己的开发环境里更新PHP的版本。那么,你呢?

笔者使用的是Linux的openSUSE42.1发行版,Yast里面还没有PHP7的安装包,于是乎只能自己手动编译安装了。作为一个PHP开发者,我是非常希望能够学会编译安装PHP7的,之前试过几次,但是每次安装都要上网找各种资料,于是乎,这次安装成功后就想把自己的安装过程以及遇到的问题记录下来,方便以后查阅和分享给需要的人。

下载源码并解压

进入正题,要编译安装PHP7,首先当然要下载PHP7的源码。你可以到github上clone,也可以到PHP官网下载。下载后解压到 /usr/local/src 目录,并将目录重命名为php7。进入目录。

配置编译参数

生成配置文件

./buildconf

配置

./configure /--prefix=/usr/local/php7 /--exec-prefix=/usr/local/php7 /--bindir=/usr/local/php7/bin /--sbindir=/usr/local/php7/sbin /--includedir=/usr/local/php7/include /--libdir=/usr/local/php7/lib/php /--mandir=/usr/local/php7/php/man /--with-config-file-path=/usr/local/php7/etc /--with-mysql-sock=/var/run/mysql/mysql.sock /--with-mcrypt=/usr/include /--with-mhash /--with-openssl /--with-mysqli=shared,mysqlnd /--with-pdo-mysql=shared,mysqlnd /--with-gd /--with-iconv /--with-zlib /--enable-zip /--enable-inline-optimization /--disable-debug /--disable-rpath /--enable-shared /--enable-xml /--enable-bcmath /--enable-shmop /--enable-sysvsem /--enable-mbregex /--enable-mbstring /--enable-ftp /--enable-gd-native-ttf /--enable-pcntl /--enable-sockets /--with-xmlrpc /--enable-soap /--without-pear /--with-gettext /--enable-session /--with-curl /--with-jpeg-dir /--with-freetype-dir /--enable-opcache /--enable-fpm /--disable-cgi /--with-fpm-user=nginx /--with-fpm-group=nginx /--without-gdbm /--disable-fileinfo 

参数说明

prefix PHP7安装的根目录

with-config-file-path PHP7的配置文件目录

执行完上面的配置命令后的结果如下图所示:

 

 执行上面命令的过程中会遇到一些依赖缺少的提示,下面列出我遇到的依赖问题:

错误:

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

解决:

zypper install libxml2-devel

错误:

configure: WARNING: unrecognized options: --with-mysql

解决:

取消这个选项,这个选项是不存在的

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表