您的位置 首页 使用教程 RAKsmart教程:Ubuntu安装PHP8.0

RAKsmart教程:Ubuntu安装PHP8.0

PHP是一种流行的Web开发脚本语言,PHP脚本可以在Linux、macOS、Windows和许多其他Unix系统上执行。这篇文章带大家了解下RAKsmart Ubuntu 20.04 | Ubuntu 18.04 Linux系统上安装PHP 8.0版本操作步骤。

一、系统更新

通过运行以下命令,将所有系统软件包更新为最新版本。

sudo apt update
sudo apt -y upgrade

 

升级后重新启动很重要,命令如下:

sudo systemctl reboot

 

二、添加OndrejSuryPPA存储库

最新的PHP软件包可在OndrejSuryPPA存储库中获得,运行下面共享的命令,以将此存储库添加到您的Ubuntu系统。

sudo apt update
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
sudo add-apt-repository ppa:ondrej/php

 

当提示您添加存储库时,按Enter键:

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.

 

从更新输出中,你应该能看到添加的存储库:

Hit:1 http://mirror.hetzner.de/ubuntu/packages focal InRelease
Hit:2 http://mirror.hetzner.de/ubuntu/packages focal-updates InRelease
Hit:3 http://mirror.hetzner.de/ubuntu/packages focal-backports InRelease
Hit:4 http://mirror.hetzner.de/ubuntu/packages focal-security InRelease
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease [23.9 kB]
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:7 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:8 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages [74.8 kB]
Get:11 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main i386 Packages [20.2 kB]
Get:12 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main Translation-en [28.2 kB]
Fetched 147 kB in 1s (158 kB/s)
Reading package lists... Done

 

三、Ubuntu 20.04 | 18.04安装PHP 8.0

更新APT索引只是为了确保可以安装软件包:

sudo apt update

 

然后在Ubuntu 20.04 | 18.04 Linux系统上安装PHP 8.0:

 sudo apt install php8.0

 

y键开始安装:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-bin libapache2-mod-php8.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libgdbm-compat4 libjansson4 liblua5.2-0 libmagic-mgc libmagic1
  libperl5.30 perl perl-modules-5.30 php-common php8.0-cli php8.0-common php8.0-opcache php8.0-readline
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear file perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
  libb-debug-perl liblocale-codes-perl
Recommended packages:
  apache2
The following NEW packages will be installed:
  apache2-bin libapache2-mod-php8.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libgdbm-compat4 libjansson4 liblua5.2-0 libmagic-mgc libmagic1
  libperl5.30 perl perl-modules-5.30 php-common php8.0 php8.0-cli php8.0-common php8.0-opcache php8.0-readline
0 upgraded, 20 newly installed, 0 to remove and 7 not upgraded.
Need to get 13.0 MB of archives.
After this operation, 78.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

 

确认服务器上的默认PHP版本:

$ php -v
PHP 8.0.0RC3 (cli) (built: Oct 31 2020 17:06:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0RC3, Copyright (c), by Zend Technologies

 

四、Ubuntu 20.04 | 18.04安装PHP 8.0扩展

要在Ubuntu 20.04 | 18.04上安装PHP 8扩展,请使用以下命令语法:

sudo apt install php8.0-<extension>

 

相关推荐:

RAKsmart教程:CentOS 7安装MySQL

RAKsmart教程:CentOS8系统安装Nginx

热门文章