How to install PHP extensions on Linux

watch 2m, 46s
views 2

12:58, 04.07.2022

Article Content
arrow

  • Installing PHP 7.4 for Apache
  • PHP 7.4 Installation Guide for Nginx
  • How to install PHP extensions on Linux
  • A little bit about PECL and conclusion

During the initial configuration of the server, one of the most important steps is the installation of PHP extensions – they are needed for most CMS, including the popular WordPress, Magento, and Laravel. In this article, we will tell you which PHP scripts must be installed and how to do it through the console. We will install it on Ubuntu 20.04, but the syntax of the commands described below can be adapted to any other Linux system.

Installing PHP 7.4 for Apache

Users of this web server only need to execute two commands sequentially:

sudo apt update
sudo apt install php libapache2-mod-php

And then restart the web server so that the changes take effect and the PHP scripts start working:

sudo systemctl restart apache2

PHP 7.4 Installation Guide for Nginx

This web server does not support PHP processing out of the box, so it will need a FastCGI - PHP–FPM process manager to work. Through the console we drive in:

sudo apt update
sudo apt install php-fpm

Upon completion of the installation, the service will start working, you will not even need to reboot. You can check the status of its work using the command:

systemctl status php7.4-fpm

And now we proceed directly to the installation of PHP extensions.

how to install php extensions on linux

How to install PHP extensions on Linux

These package modules are compiled libraries that extend the basic functions of PHP. They are often needed for programmers and webmasters to work, as they help to implement many interesting features. To install packages, use the command:

sudo apt install php-[extname]

Only instead of [extname] it is necessary to substitute the name of the plugin of interest. For WordPress, for example, you may need the following:

  • php-mysql — needed when working with a database, most often put together with the main language package;
  • php-ctype — is needed in cases when a Fatal error occurs during operation: Call to undefined function ctype_digit() in /wp-admin/includes/file.php;
  • php-dom — sometimes needed when working with Windows hosting, but most often not in demand;
  • php-exif — required to work with photo meta data;
  • php-gd — used when processing images, needed often;
  • php-iconv — converting a string from one encoding to another;
  • php-json — JSON support;
  • php-posix — used in the WP_Filesystem_Direct class
  • php-mbstring — required, needed for string processing;
  • php-zip, php-zlib — useful for those who work with archives.

In general, the complete list of all existing PHP extensions is estimated at hundreds of different modules, most of which are highly specialized and are used by IT specialists to optimize work tasks.

You can also install PHP extensions via the ISPmanager control panel or any other – there in the corresponding tab you can download and install all the necessary packages without a console.

A little bit about PECL and conclusion

We should also mention the repository of native extensions for PHP written in the C language. They are used in cases when it is not possible to implement some ideas in PHP - for example, reloading operators. All modules in the PECL repository are developed in strict accordance with the coding standards adopted by the PHP development team, so the quality of their work should not cause you any doubts.

If you still have questions about how to install and connect PHP extensions to your server, contact our specialists via Livechat or by phone. We will answer all your questions within our competence.

Share

Was this article helpful to you?

VPS popular offers

-15%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
80 Mbps
DDoS Protected SSD-wKVM 8192 Windows

101 /mo

/mo

Billed annually

-20.5%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
8 TB
KVM-SSD 8192 Metered Linux

57 /mo

/mo

Billed annually

-9.9%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 2048 Linux

6.34 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 4096 Linux

25.9 /mo

/mo

Billed annually

CPU
CPU
8 Epyc Cores
RAM
RAM
32 GB
Space
Space
200 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 32768
OS
CentOS
Software
Software
Keitaro
/mo

Billed monthly

-9.1%

CPU
CPU
6 Epyc Cores
RAM
RAM
16 GB
Space
Space
150 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 16384 Windows

66.5 /mo

/mo

Billed annually

-8.4%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
75 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-wKVM-SSD 2048 Windows

37.4 /mo

/mo

Billed annually

-10%

CPU
CPU
8 Epyc Cores
RAM
RAM
32 GB
Space
Space
200 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 32768 Linux

96.8 /mo

/mo

Billed annually

-9%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
Unlimited
wKVM-SSD 16384 Windows

57.7 /mo

/mo

Billed annually

-10%

CPU
CPU
8 Xeon Cores
RAM
RAM
32 GB
Space
Space
200 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 32768 Linux

93.5 /mo

/mo

Billed annually

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.