Command Line Install Using APT for PHP 7
suggest changeThis installs the PHP CLI only. To serve PHP on the web, also install a web server such as Apache or Nginx, or use the built-in server (
php -S, available since PHP 5.4). Thephp7.0package name is specific to older Ubuntu releases; current Ubuntu packages are namedphporphp8.x.
If you are in a Ubuntu version below 16.04 and want to use PHP 7 anyway, you can add Ondrej’s PPA repository by doing: sudo add-apt-repository ppa:ondrej/php
Make sure that all of your repositories are up to date:
sudo apt-get update
After updating your system’s repositories, install PHP:
sudo apt-get install php7.0
Let’s test the installation by checking the PHP version:
php --version
This should output something like this.
Note: Your output will be slightly different.
PHP 7.0.8-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
You now have the capability to run PHP from the command line.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents