Make sure your Ubuntu is up to date and patched.

$ sudo apt update
$ sudo apt upgrade

PHP is available within Ubuntu’s default software repositories, making it possible to install it using conventional package management tools. After confirming the installation, apt will install PHP and all required dependencies.

$ sudo apt install php -y
$ php -v

# Returns an error in fresh install
Command 'php' not found, but can be installed with:
sudo apt install php7.4-cli

# Returns PHP version
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

PHP extensions are compiled libraries that extend the core functionality of PHP. Extensions are available as packages and can be easily installed with:

$ sudo apt-get install -y php-{curl,dom,fileinfo,gd,iconv,intl,json,mbstring,pdo,phar,simplexml,xml,zip}

Have fun!

Share:

Leave a Reply

Your email address will not be published.