By Arunkumar Ganesan on August 22, 2021
Beginner

Take Backup/Snapshot

Always before any upgrade, take a snapshot of the VM.

Spin a new VM from the snapshot if you are not sure of the upgrade


Login to the VM

SSH to the VM instance of Wordpress


Add PHP repository

Ubuntu 18.04 only ships php 7.2 in the default repository. apt-get will not install php 7.4. So first add the repository manually

sudo add-apt-repository ppa:ondrej/php


Update and upgrade the repository

sudo apt update
sudo apt upgrade


Install PHP 7.4

Install Php 7.4 and related extensions

apt-get install php7.4 php7.4-cli php7.4-fpm php7.4-mysql php7.4-json php7.4-opcache php7.4-mbstring php7.4-xml php7.4-gd php7.4-curl


Check Php version. Should get 7.4

$ php -v
PHP 7.4.22 (cli) (built: Jul 30 2021 13:07:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
   with Zend OPcache v7.4.22, Copyright (c), by Zend Technologies


Install fpm for NGINX

sudo apt install php7.4-fpm


Configure fpm in the sites

edit the server block files under sites available

/etc/nginx/sites-available$ sudo vim kaykaribasket.lmnas.com


Edit the fpm from 7.2 to 7.4 like below

fastcgi_pass unix:/run/php/php7.4-fpm.sock;


Check Niginx config, Restart Nginx, Restart fpm

$ sudo nignx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo service nginx restart
$ sudo service php7.4-fpm restart


Note: To Switch php version use below command

sudo update-alternatives --config php


Finally check the website if it works fine


More articles on Ningx WordPress



More articles on Ningx WordPress
Comments

No comments yet.

Add a comment
Ctrl+Enter to add comment