How to install PHP on ubuntu

藏色散人
Release: 2023-02-28 15:20:02
Original
4494 people have browsed it

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
Copy after login

2. Verify PHP

The following command can get the version number.

php -v
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

Ubuntu 18.04 Apache2, because Apache2 contains native support for PHP, installation is much simpler.

apt install libapache2-mod-php
Copy after login

The following command can check the installation status of php components.

apt-cache search --names-only ^php
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!