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

-10%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 4096
OS
CentOS
Software
Software
Keitaro

18.1 /mo

/mo

Billed annually

-18.4%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
75 GB SSD
Bandwidth
Bandwidth
2 TB
wKVM-SSD 2048 Metered Windows

24 /mo

/mo

Billed annually

-16.2%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
60 Mbps
DDoS Protected SSD-KVM 4096 Linux

67 /mo

/mo

Billed annually

-10%

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

77.54 /mo

/mo

Billed annually

-4.5%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 4096 Windows

16.88 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 2048 Linux

7.7 /mo

/mo

Billed annually

-24.7%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
4 TB
KVM-SSD 4096 Metered Linux

31 /mo

/mo

Billed annually

-10%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
40 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 1024 Linux

6.1 /mo

/mo

Billed annually

-16.3%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
30 GB SSD
Bandwidth
Bandwidth
40 Mbps
DDoS Protected SSD-KVM 2048 Linux

48 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
400 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 16384 Linux

39.97 /mo

/mo

Billed annually

Other articles on this topic

How to do MySQL dump
How to do MySQL dump
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.