찾다
php教程php手册【安装PHP】如何在openSUSE42.1下编译安装PHP7

首先推荐一篇文章php 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog。 里面说到是否会去使用PHP7,就个人而言,我是毫不犹豫地使用的,但是生产环境就不是我说了算,所以只能自己在自己的开发环境里更新PHP的版本。那么,你呢?

首先推荐一篇文章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

配置

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

 

参数说明

prefix PHP7安装的根目录

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

 

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

 

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

错误:

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

解决:

zypper <span style="color: #0000ff;">install</span> libxml2-devel

错误:

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

解决:

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

错误:

configure: error: jpeglib.h not found.

解决:

zypper <span style="color: #0000ff;">install</span> libjpeg-devel

错误:

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

解决:

zypper <span style="color: #0000ff;">install</span> libmcrypt-devel

错误:

checking <span style="color: #0000ff;">for</span><span style="color: #000000;"> recode support... yes
configure: error: Can not </span><span style="color: #0000ff;">find</span> recode.h anywhere under /usr /usr/local /usr /opt.

解决:

zypper <span style="color: #0000ff;">install</span> librecode-devel

总的来说,在配置的时候遇到没有的就打开Yast搜一下,如果有的话就安装,然后重新编译看还需要那些,如果在Yast找不到,那就上网找一下Google。

编译和安装PHP7

<span style="color: #0000ff;">make</span> && <span style="color: #0000ff;">make</span> <span style="color: #0000ff;">install</span>

其中,make之后可以选择make test。只是一个可选步骤,不执行不知道有什么问题,不过笔者暂时还没遇到。

 

查看安装成功后的PHP7目录

编译安装成功后,查看PHP7的安装目录`ls /usr/local/php7`:

 

设置PHP7的配置文件

<span style="color: #0000ff;">cp</span> /usr/local/src/php7/php.ini-production /usr/local/php7/etc/<span style="color: #000000;">php.ini
</span><span style="color: #0000ff;">cp</span> /usr/local/src/sapi/fpm/init.d.php-fpm /etc/init.d/php-<span style="color: #000000;">fpm
</span><span style="color: #0000ff;">cp</span> /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-<span style="color: #000000;">fpm.conf
</span><span style="color: #0000ff;">cp</span> /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

 

设置环境变量

在/etc/profile 文件的最后一行加上

export PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH


然后执行 source /etc/profile 

设置PHP日志目录和php-fpm进程文件(php-fpm.sock)目录

<span style="color: #0000ff;">mkdir</span> -p /var/log/php-fpm/ && <span style="color: #0000ff;">mkdir</span> -p /var/run/php-fpm && cd /var/run/ && <span style="color: #0000ff;">chown</span> -R nginx:nginx php-fpm

将PHP设置为开机启动

<span style="color: #0000ff;">chmod</span> +x /etc/init.d/php-<span style="color: #000000;">fpm
chkconfig php</span>-fpm on

可以用chkconfig命令查看开机启动服务列表。

启动PHP服务

service php-fpm start

通过ps aux | grep 'php'查看PHP是否启动成功

至此,PHP7就安装成功了,你也开始使用PHP7吧!


성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

SecList

SecList

SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구