Home>Article>Backend Development> How to install PHP on ubuntu
How to install PHP on ubuntu?
1. Install PHP
Under Ubuntu 18.04, open the Ubuntu terminal window (ctrl alt t) and run the following command to quickly and easily install PHP.
Recommended: "PHP Tutorial"
When this article was written, the default version installed was PHP 7.2.
apt update && apt upgrade apt install php
2. Verify PHP
The following command can get the version number.
php -v
Here is the output example:
root@wp2019:~# php -v PHP 7.2.19-0ubuntu0.18.04.1 (cli) (built: Jun 4 2019 14:48:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.19-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
3. Install other necessary PHP components
Ubuntu 16.04 Nginx Use the following parameters to install.
apt install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml
Ubuntu 18.04 Nginx Use the parameters below to install.
apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
Ubuntu 18.04 Apache2, because Apache2 contains native support for PHP, installation is much simpler.
apt install libapache2-mod-php
The following command can check the installation status of php components.
apt-cache search --names-only ^php
The above is the detailed content of How to install PHP on ubuntu. For more information, please follow other related articles on the PHP Chinese website!