Now Reading
How To Install PHP 7 On Ubuntu 20.04 LTS
Dark Light

How To Install PHP 7 On Ubuntu 20.04 LTS

Avatar
aerial photo of brown moutains

This tutorial explains all the steps required to install the default distribution of PHP 7 on Ubuntu 20.04 LTS. The steps should be similar on other versions of Ubuntu and Linux based systems. In case you are planning to use PHP with the Apache HTTP Server and MySQL database server, you can install Apache 2 and MySQL 8 before starting the installation of PHP 7. It can be done by following the guides – How To Install Apache 2 On Ubuntu 20.04 LTS and How To Install MySQL 8 on Ubuntu 20.04 LTS. Also, PHP can be used with NGINX Web Server instead of the Apache HTTP Server. NGINX is widely used as a load balancer and reverse proxy for Apache Web Server and other servers. You can follow How To Install And Configure Nginx on Ubuntu 20.04 LTS and Configure Virtual Host Or Server Block On Nginx. Install PHP 7 In this step, we will install PHP 7.4, the default PHP package available for Ubuntu 20.04 LTS release. It can be installed using the command as shown below. # Refresh indexessudo apt-get update# Install PHP 7.4 on Ubuntu 20.04 LTSsudo apt-get install php7.4# Verify PHPphp –version# OutputPHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )Copyright (c) The PHP GroupZend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies# Autocleansudo apt-get autoclean# Autoremovesudo apt-get autoremove# ORsudo apt-get –purge autoremove It will ask to confirm the installation. Press Y and hit Enter to confirm the installation. The important paths and files of the PHP installation are /usr/lib/php/7.4, /usr/bin/php7.4, and /etc/php/7.4/cli/php.ini. Install Apache2 Module Use the below-mentioned commands to install the Apache2 Module for PHP. Also, refer to How To Install Apache 2 On Ubuntu 20.04 LTS. # Install Apache2 Module if not installed by defaultsudo apt-get install libapache2-mod-php7.4 PHP for NGINX We can install PHP FPM and configure it for Nginx. This will eliminate the need for the Apache Web Server and Nginx can handle the PHP requests. # FPMsudo apt-get install php7.4-fpm You can follow How To Install PHP For Nginx On Ubuntu 20.04 LTS for further details. Install MySQL Extension Use the below-mentioned commands to install the MySQL extension for PHP 7. Also, refer to How To Install MySQL 8 on Ubuntu 20.04 LTS. # Install MySQL Extensionsudo apt-get install php7.4-mysql# Install MySQL Extension – Required for WordPress Installationsudo apt-get install php-mysql Additional Extensions You can also install the additional extensions in order to fully support a web application. Some of these packages might not be required in your scenario, hence it’s totally optional to install these extensions. # Install CGI and CLI if not installed by defaultsudo apt-get install php7.4-common php7.4-cgi php7.4-cli # Install CURL and JSON extensionssudo apt-get install php7.4-curl php7.4-json# Install PHP GD and Imagicksudo apt-get install php7.4-gd php-imagick# Multibyte String, Internationalization and Spell Checksudo apt-get install php7.4-mbstring php7.4-intl php7.4-pspell# Multibyte String, Internationalization and Spell Check – Required for WordPress Installationsudo apt-get install php-mbstring php-intl php-pspell# Emailssudo apt-get install php7.4-imap# SQLite Databasesudo apt-get install php7.4-sqlite3 # Tidy and XML RPCsudo apt-get install php7.4-tidy php7.4-xmlrpc# Excelsudo apt-get install php7.4-xsl Install OPcache to enable caching at the bytecode level. # Install OPcache extensionsudo apt-get install php7.4-opcache Install the extensions to handle compressed files. # Install Zipsudo apt-get install php7.4-zip These are the steps required to install PHP 7 on Ubuntu 20.04 LTS and the additional packages that are mostly required for the website development. Summary This tutorial provided all the steps required to install PHP 7 on Ubuntu 20.04 LTS and also enable the extension for the Apache HTTP Server. We have also installed the popular extensions for PHP which are required to host web applications. How To Install PHP For Nginx On Ubuntu 20.04 LTS

Touch The Stars

0 / 5

Your page rank:

What's Your Reaction?
Excited
0
Funny
0
In Love
0
Like It
0
Not Sure
0
View Comments (0)

Leave a Reply

Your email address will not be published.


Copyrights © 2021 Lucid.Hive.Systems. All Rights Reserved.