My server configuration (DigitalOcen):

  • 4GB RAM | 80 GB Disk
  • Ubuntu 16.04 x64 (NGINX) - WordPress

Current PHP version: 7.0.33

  • Reason to upgrade: WordPress Error - PHP Update Required

Kindly help.
Thank you!

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @chinmayrajyaguru,

You can actually upgrade the PHP version, you can just install a new one.

Firstly, to be able to install a certain PHP version, in this case, 7.2 you’ll need to add a certain repository to your system

sudo apt-add-repository ppa:ondrej/php

Update the repository index.

sudo apt update

Install PHP 7.4 with the below command.

sudo apt install -y php7.4 php7.4-cli php7.4-common php7.4-fpm

To install extensions run

sudo apt install -y php7.4-mysql php7.4-dom php7.4-simplexml php7.4-ssh2 php7.4-xml php7.4-xmlreader php7.4-curl  php7.4-exif  php7.4-ftp php7.4-gd  php7.4-iconv php7.4-imagick php7.4-json  php7.4-mbstring php7.4-posix php7.4-sockets php7.4-tokenizer

The above are the required extensions for your WordPRess installation. Having said that it’s good to have these extensions as well.

sudo apt install -y php7.4-mysqli php7.4-pdo  php7.4-sqlite3 php7.4-ctype php7.4-fileinfo php7.4-zip php7.4-exif

That’s it, you now have your PHP version installed.

  • Respected @KFSys
    First, thank you so much!!! As per your guidelines, I have successfully installed it.

    STEP 4 - Warning: click here to open warning image

    To activate PHP 7.4 on the server:
    Configure the PHP Processor

    sudo nano /etc/php/7.4/fpm/php.ini
    

    Find: cgi.fix_pathinfo
    Remove semi-colon and set 0

    cgi.fix_pathinfo=0
    
    sudo systemctl restart php7.4-fpm
    

    Configure Nginx to Use the PHP Processor

    sudo nano /etc/nginx/sites-available/default
    

    Find out “`
    location ~ .php$ {
    ....
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; —- Remove this line by commenting ’#’

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

    sudo nginx -t
    sudo systemctl reload nginx
    

    You can now test php by using phpinfo() function or use php -v command into the terminal.

  • I believe there’s a typo in your list of extensions. You list

    php7.4--json
    

    which errors for me. A single hyphen works correctly.

    php7.4-json
    

After bouncing around between a lot of tutorials, I finally got this to work. Here are the commands I needed:

sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.4
sudo apt-get install php7.4-mysql
php -v (check to make sure PHP 7.4 is installed)
sudo apt install php7.4-fpm php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-mysql php7.4-cli php7.4-zip php7.4-curl
sudo a2dismod php7.0
sudo a2enmod php7.4
sudo service apache2 restart
Submit an Answer