Step 1: Install PHP
apt-get install php7.4 -y
apt-get install php7.4-fpm -y
apt-get install php7.4-dev -y
Step 2: Install some extensions:
apt-get install -y php7.4-gd php7.4-imap php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring
apt-get install -y php7.4-mongodb
Result:
root@tutorialspots:~# apt-get install -y php7.4-gd php7.4-imap php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring Reading package lists... Done Building dependency tree Reading state information... Done php7.4-json is already the newest version (7.4.3-4ubuntu2.7). php7.4-json set to manually installed. The following additional packages will be installed: libc-client2007e libonig5 mlock Suggested packages: uw-mailutils The following NEW packages will be installed: libc-client2007e libonig5 mlock php7.4-gd php7.4-imap php7.4-intl php7.4-ldap php7.4-mbstring 0 upgraded, 8 newly installed, 0 to remove and 52 not upgraded. Need to get 1,341 kB of archives. After this operation, 4,128 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 mlock amd64 8:2007f~dfsg-7 [12.0 kB] Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libc-client2007e amd64 8:2007f~dfsg-7 [578 kB] Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 libonig5 amd64 6.9.4-1 [142 kB] Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 php7.4-gd amd64 7.4.3-4ubuntu2.7 [28.0 kB] Get:5 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 php7.4-imap amd64 7.4.3-4ubuntu2.7 [29.7 kB] Get:6 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 php7.4-intl amd64 7.4.3-4ubuntu2.7 [126 kB] Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 php7.4-ldap amd64 7.4.3-4ubuntu2.7 [29.6 kB] Get:8 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 php7.4-mbstring amd64 7.4.3-4ubuntu2.7 [396 kB] Fetched 1,341 kB in 1s (984 kB/s) Selecting previously unselected package mlock. (Reading database ... 116188 files and directories currently installed.) Preparing to unpack .../0-mlock_8%3a2007f~dfsg-7_amd64.deb ... Unpacking mlock (8:2007f~dfsg-7) ... Selecting previously unselected package libc-client2007e. Preparing to unpack .../1-libc-client2007e_8%3a2007f~dfsg-7_amd64.deb ... Unpacking libc-client2007e (8:2007f~dfsg-7) ... Selecting previously unselected package libonig5:amd64. Preparing to unpack .../2-libonig5_6.9.4-1_amd64.deb ... Unpacking libonig5:amd64 (6.9.4-1) ... Selecting previously unselected package php7.4-gd. Preparing to unpack .../3-php7.4-gd_7.4.3-4ubuntu2.7_amd64.deb ... Unpacking php7.4-gd (7.4.3-4ubuntu2.7) ... Selecting previously unselected package php7.4-imap. Preparing to unpack .../4-php7.4-imap_7.4.3-4ubuntu2.7_amd64.deb ... Unpacking php7.4-imap (7.4.3-4ubuntu2.7) ... Selecting previously unselected package php7.4-intl. Preparing to unpack .../5-php7.4-intl_7.4.3-4ubuntu2.7_amd64.deb ... Unpacking php7.4-intl (7.4.3-4ubuntu2.7) ... Selecting previously unselected package php7.4-ldap. Preparing to unpack .../6-php7.4-ldap_7.4.3-4ubuntu2.7_amd64.deb ... Unpacking php7.4-ldap (7.4.3-4ubuntu2.7) ... Selecting previously unselected package php7.4-mbstring. Preparing to unpack .../7-php7.4-mbstring_7.4.3-4ubuntu2.7_amd64.deb ... Unpacking php7.4-mbstring (7.4.3-4ubuntu2.7) ... Setting up mlock (8:2007f~dfsg-7) ... Setting up php7.4-intl (7.4.3-4ubuntu2.7) ... Creating config file /etc/php/7.4/mods-available/intl.ini with new version Setting up php7.4-ldap (7.4.3-4ubuntu2.7) ... Creating config file /etc/php/7.4/mods-available/ldap.ini with new version Setting up libc-client2007e (8:2007f~dfsg-7) ... Setting up libonig5:amd64 (6.9.4-1) ... Setting up php7.4-gd (7.4.3-4ubuntu2.7) ... Creating config file /etc/php/7.4/mods-available/gd.ini with new version Setting up php7.4-imap (7.4.3-4ubuntu2.7) ... Creating config file /etc/php/7.4/mods-available/imap.ini with new version Setting up php7.4-mbstring (7.4.3-4ubuntu2.7) ... Creating config file /etc/php/7.4/mods-available/mbstring.ini with new version Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.7) ... Processing triggers for php7.4-fpm (7.4.3-4ubuntu2.7) ... NOTICE: Not enabling PHP 7.4 FPM by default. NOTICE: To enable PHP 7.4 FPM in Apache2 do: NOTICE: a2enmod proxy_fcgi setenvif NOTICE: a2enconf php7.4-fpm NOTICE: You are seeing this message because you have apache2 package installed. Processing triggers for libc-bin (2.31-0ubuntu9.2) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for php7.4-cli (7.4.3-4ubuntu2.7) ... root@tutorialspots:~# apt-get install -y php7.4-mongodb Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'php-mongodb' instead of 'php7.4-mongodb' The following NEW packages will be installed: php-mongodb 0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded. Need to get 387 kB of archives. After this operation, 1,206 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 php-mongodb amd64 1.6.1-4build1 [387 kB] Fetched 387 kB in 1s (352 kB/s) Selecting previously unselected package php-mongodb. (Reading database ... 116265 files and directories currently installed.) Preparing to unpack .../php-mongodb_1.6.1-4build1_amd64.deb ... Unpacking php-mongodb (1.6.1-4build1) ... Setting up php-mongodb (1.6.1-4build1) ... Processing triggers for php7.4-cli (7.4.3-4ubuntu2.7) ... Processing triggers for libapache2-mod-php7.4 (7.4.3-4ubuntu2.7) ... Processing triggers for php7.4-fpm (7.4.3-4ubuntu2.7) ... NOTICE: Not enabling PHP 7.4 FPM by default. NOTICE: To enable PHP 7.4 FPM in Apache2 do: NOTICE: a2enmod proxy_fcgi setenvif NOTICE: a2enconf php7.4-fpm NOTICE: You are seeing this message because you have apache2 package installed.
Step 3:
systemctl enable php7.4-fpm
systemctl start php7.4-fpm
Result:
root@tutorialspots:~# systemctl enable php7.4-fpm Synchronizing state of php7.4-fpm.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable php7.4-fpm root@tutorialspots:~# systemctl start php7.4-fpm
Step 4: edit file /etc/php/7.4/fpm/pool.d/www.conf
change line:
listen = /run/php/php7.4-fpm.sock
to
listen = 127.0.0.1:9000
Step 5: Restart php-fpm
systemctl restart php7.4-fpm