php 7.3是php的最新版本,如果你想装指定版本的php,这篇文章对你有很大的帮助。本文将帮助你在ubuntu 18.04,16.04上通过ppa的方式安装php 7.3 7.2和7.0。

安装php 7.3

通过下列命令安装php 7.3

$ 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的版本

$ 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

$ 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的版本

$ 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

$ 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的版本

$ 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

$ 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的版本

$ 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模块

$ 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版本。

$ sudo apt-get install php7.2-mysql php7.2-curl php7.2-json php7.2-cgi php7.2-xsl

安装完成后,现在就可以开始php开发了。

总结

以上所述是www.887551.com给大家介绍的在ubuntu 18.04上安装php 7.3 7.2和7.0的方法,希望对大家有所帮助