这篇文章主要介绍了在Ubuntu 18.04上安装PHP 7.3 7.2和7.0的方法,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下
PHP 7.3是PHP的最新版本,如果你想装指定版本的PHP,这篇文章对你有很大的帮助。本文将帮助你在Ubuntu 18.04,16.04上通过PPA的方式安装PHP 7.3 7.2和7.0。
安装PHP 7.3
通过下列命令安装PHP 7.3
1
2
3
4
|
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install -y php7.3 |
安装完成后,使用如下命令检查PHP的版本
1
2
3
4
5
|
$ php -v PHP 7.3.3-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:31:49) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.3-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies |
安装PHP 7.2
通过下列命令安装PHP 7.2
1
2
3
4
|
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install -y php7.2 |
安装完成后,使用如下命令检查PHP的版本
1
2
3
4
5
|
$ php -v PHP 7.2.16-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:23:29) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.16-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies |
安装PHP 7.1
通过下列命令安装PHP 7.1
1
2
3
4
|
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install -y php7.1 |
安装完成后,使用如下命令检查PHP的版本
1
2
3
4
5
|
$ php -v PHP 7.1.27-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:02:25) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.27-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies |
安装PHP 7.0
通过下列命令安装PHP 7.0
1
2
3
4
|
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install -y php7.0 |
安装完成后,使用如下命令检查PHP的版本
1
2
3
4
5
|
$ php -v PHP 7.0.33-5+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 8 2019 09:49:15) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.33-5+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies |
安装PHP 7模块
使用如下命令安装PHP 7模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
$ sudo apt-cache search php7* php-all-dev - package depending on all supported PHP development packages php7.0 - server-side, HTML-embedded scripting language (metapackage) php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary) php7.0-cli - command-line interpreter for the PHP scripting language php7.0-common - documentation, examples and common module for PHP php7.0-curl - CURL module for PHP php7.0-dev - Files for PHP7.0 module development php7.0-gd - GD module for PHP php7.0-gmp - GMP module for PHP ... ... ... php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP php7.1-xmlrpc - XMLRPC-EPI module for PHP php7.1-zip - Zip module for PHP php7.1-opcache - Zend OpCache module for PHP php7.1 - server-side, HTML-embedded scripting language (metapackage) php7.1-xsl - XSL module for PHP (dummy) ... ... php7.2-bcmath - Bcmath module for PHP php7.2-bz2 - bzip2 module for PHP php7.2-cgi - server-side, HTML-embedded scripting language (CGI binary) php7.2-cli - command-line interpreter for the PHP scripting language php7.2-common - documentation, examples and common module for PHP php7.2-curl - CURL module for PHP php7.2-dba - DBA module for PHP |
用如下命令,按需安装PHP扩展模块,安装之前,确保安装正确的PHP版本。我自己用php7.3所以安装7.3的模块!大家根据自己需求安装。
sudo apt-get install php7.3-bcmath php7.3-bz2 php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-dba php7.3-dev \
php7.3-enchant php7.3-fpm php7.3-gd php7.3-gmp php7.3-imap php7.3-interbase php7.3-intl php7.3-json php7.3-ldap \
php7.3-mbstring php7.3-mysql php7.3-odbc php7.3-opcache php7.3-pgsql php7.3-phpdbg php7.3-pspell php7.3-readline \
php7.3-recode php7.3-snmp php7.3-soap php7.3-sqlite3 php7.3-sybase php7.3-tidy php7.3-xml php7.3-xmlrpc php7.3-xsl \
php7.3-zip$
安装完成后,现在就可以开始php开发了。
总结
以上所述是小编给大家介绍的在Ubuntu 18.04上安装PHP 7.3 7.2和7.0的方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!