云网牛站
所在位置:首页 > Linux教程 > 给在Linux虚拟机里运行的FreeBSD 12系统安装PHP 7.2

给在Linux虚拟机里运行的FreeBSD 12系统安装PHP 7.2

2019-03-06 11:27:59作者:戴均益稿源:云网牛站

如果你在Linux虚拟机VirtualBox里运行FreeBSD 12系统,可以安装PHP 7.2,请按以下步骤操作。安装虚拟机请参考在Ubuntu 18.04/Debian 9上安装VirtualBox 6.0的方法一文。对于PHP 7.3,请参考给在Linux虚拟机里运行的FreeBSD 12安装PHP 7.3一文。

 

步骤一、更新ports tree

首先使用portsnap命令更新FreeBSD系统的ports tree:

$ jmutai@freebsd:~ % su -

Password:

root@freebsd:~# portsnap fetch update

Looking up portsnap.FreeBSD.org mirrors... 5 mirrors found.

Fetching public key from ec2-ap-southeast-2.portsnap.freebsd.org... done.

Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org... done.

Fetching snapshot metadata... done.

Fetching snapshot generated at Wed Mar 06 01:19:28 UTC 2019:

Extracting snapshot... done.

Verifying snapshot integrity... done.

Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org... done.

Fetching snapshot metadata... done.

Updating from Wed Mar 06 01:19:28 UTC 2019 to Wed Mar 06 09:15:19 UTC 2019.

Fetching 5 metadata patches... done.

Applying metadata patches... done.

Fetching 0 metadata files... done.

Fetching 78 patches.

(78/78) 100.00%  done.

done.

Applying patches... 

done.

Fetching 3 new ports or files... done.

/usr/ports was not created by portsnap.

You must run 'portsnap extract' before running 'portsnap update'.

首次运行Portsnap时,需要将快照解压缩到/usr/ports:

# portsnap extract

应该能返回如下行:

Building new INDEX files... done.

然后运行portsnap fetch update命令确认:

# portsnap fetch update

Looking up portsnap.FreeBSD.org mirrors... 5 mirrors found.

Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.

Latest snapshot on server matches what we already have.

No updates needed.

Ports tree is already up to date.

默认情况下,Ports Collection本身存储为/usr/ports的子目录。

 

步骤二、在FreeBSD上安装PHP 7.2

有两种方法可以在FreeBSD上安装PHP 7.2:

1、从二进制包安装。

2、使用端口从源安装。

方法1:从二进制文件在FreeBSD上安装PHP 7.2

如果尚未下载并安装pkg:

# /usr/sbin/pkg

The package management tool is not yet installed on your system.

Do you want to fetch and install it now? [y/N]: y

Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/latest, please wait...

Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done

Installing pkg-1.10.5_5...

the most recent version of pkg-1.10.5_5 is installed

然后安装PHP 7.2:

# pkg install php72

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

php72: 7.2.10

libargon2: 20171227_1

pcre: 8.42

Number of packages to be installed: 3

The process will require 31 MiB more space.

5 MiB to be downloaded.

Proceed with this action? [y/N]: y

[1/3] Fetching php72-7.2.10.txz: 100%    3 MiB 192.9kB/s    00:18

[2/3] Fetching libargon2-20171227_1.txz: 100%   64 KiB  65.3kB/s    00:01

[3/3] Fetching pcre-8.42.txz: 100%    1 MiB  44.9kB/s    00:28

Checking integrity... done (0 conflicting)

[1/3] Installing libargon2-20171227_1...

[1/3] Extracting libargon2-20171227_1: 100%

[2/3] Installing pcre-8.42...

[2/3] Extracting pcre-8.42: 100%

[3/3] Installing php72-7.2.10...

[3/3] Extracting php72-7.2.10: 100%

确认已安装的PHP版本:

# php -v

PHP 7.2.10 (cli) (built: Dec  1 2018 01:31:03) ( NTS )

Copyright (c) 1997-2018 The PHP Group

Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

同时可以在FreeBSD上安装PHP 7.2扩展。

使用syntaxphp72-<extension>安装扩展:

# pkg install php72-curl php72-extensions php72-json php72-xml \

php72-zip php72-intl php72-mysqli php72-pdo_mysql php72-pdo \

php72-pear php72-soap php72-phar

使用以下命令查看已加载:

# php -m

方法2:从端口在FreeBSD上安装PHP 7.2

将你的工作目录更改为PHP 7.2 ports文件夹:

# cd /usr/ports/lang/php72

然后构建并安装PHP 7.2:

# make install clean

要在FreeBSD上安装PHP 7.2扩展,请执行以下操作:

# cd /usr/ports/lang/php72-extensions/

# make install clean

至此,你现在已在FreeBSD上安装了PHP 7.2。

 

相关主题

在RHEL 8系统下安装PHP 7.2和PHP 7.1的方法

精选文章
热门文章