如何在FreeBSD 12上安装PHP 7.2
时间:2020-02-23 14:33:17 来源:igfitidea点击:
如何在FreeBSD 12上安装PHP 7.3
FreeBSD是一个免费和开源的UNIX操作系统,提供了一些良好的功能,如抢占式多任务,内存保护,虚拟内存,支持监禁,多用户设施,SMP支持,广泛的安全功能等
按照以下步骤在FreeBSD服务器上安装PHP 7.2.
第1步:更新端口树
首先使用使用的FreeBSD服务器端口树更新 portsnap
命令:
$Hyman@theitroad:~ % su Password: Hyman@theitroad:~# 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 Sun Dec 9 00:19:28 UTC 2016: 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 Sun Dec 9 00:19:28 UTC 2016 to Sun Dec 9 19:15:19 UTC 2016. 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 /端口:
# portsnap extract
我们应该在输出结束时获取下面的消息。
Building new INDEX files... done.
确认一切都是最新的。
# 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.
默认情况下,端口集合本身存储为子目录 /usr/ports
。
第2步:在FreeBSD上安装PHP 7.2
有两种方式可以在FreeBSD上安装PHP 7.2.在使用端口从源中的二进制包中安装PHP 7.2
方法1:从二进制文件中安装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: 20161227_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-20161227_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-20161227_1... [1/3] Extracting libargon2-20161227_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 2016 01:31:03) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2016 Zend Technologies
在FreeBSD上安装PHP 7.2扩展
可以使用语法安装扩展 php72-<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
方法1:从端口的FreeBSD上安装PHP 7.2
将工作目录更改为PHP 7.2端口文件夹
# cd /usr/ports/lang/php72
然后构建并安装PHP 7.2
# make install clean
在FreeBSD上安装PHP 7.2的扩展,做到象下面这样:
# cd /usr/ports/lang/php72-extensions/ # make install clean