Upgrade WordPress to PHP 8.0 on Ubuntu 20.04 |18.04 With Nginx

Upgrade WordPress to PHP 8.0 on Ubuntu 20.04 18.04 With Nginx

This post shows users and new students How to Upgrade WordPress to PHP 8.0 on Ubuntu 18.04 | 20.04.

PHP-8.0 is a new version with lots of improvements and features. It is officially released on November 26, 2020.

For WordPress sites, latest version of PHP offers new features and improvements for developers. They will find useful and improvements that enhance security and performance of the PhP based application or website in the long run. 

PHP is a popular general purpose scripting programmiing language especially for the web development. It was originally developed by Danish Canadian programmer Rasmus Lerdorf in 1994. 

For the new students and new users, this post will be useful and handy if they want to learn that how to install PHP 8.0 on Ubuntu with Apache or Nginx web server.

At this time PHP-8.0 is not ready for used with WordPress but developers are still calling WordPress 5.6-beta compatible to PHP-8.0.

If PHP-8.0 works fine with core WordPress functions, then i will sure that all themes and plugins of WordPress will work fine without any issues at this time.

If you really want Upgrade WordPress to PHP-8.0, simply continue below as below steps to upgrade PHP 8.0 and use it with WordPress.

So if you have not yet installed WordPress then search on our website to learn how to install it on Ubuntu.

Upgrade to PHP 8.0 with Nginx

Some versions of Ubuntu do not have latest version of PHP including also PHP-8.0 so you can add a third party PPA repository for installing the latest version from there.

This post assumes that you are running PHP 7.4 or it’s previous versions.

Use below command to add a third party PPA repository to Ubuntu.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

After above steps we need to update and upgrade to  PHP 8.0-FPM.

sudo apt update

Next step, run the below commands to install PHP 8.0-FPM and it’s related modules.

sudo apt install php8.0-fpm php8.0-common php8.0-mysql php8.0-gmp php8.0-curl php8.0-intl php8.0-mbstring php8.0-xmlrpc php8.0-gd php8.0-xml php8.0-cli php8.0-zip

After installing PHP 8.0-FPM, run the below commands to open PHP configuration file for Nginx server.

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

The below lines is a good settings for most PHP based content management system(CMS). So Update the configuration file with these setting and save the file.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

Run below Commands to restart the Nginx server and PHP script.

sudo systemctl restart nginx.service
sudo systemctl restart php8.0-fpm.service

After above steps , run the below commands to enable PHP-8.0 support for Nginx server.

You can found Ubuntu default site configuration file at

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

After open the file, edit the php block session:

# Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;


        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one

After Edit the file, restart Nginx server to use PHP 8.0-FPM.

sudo systemctl restart nginx.service

Run the below commands to remove all PHP 7.4-FPM packages.

sudo apt-get purge `dpkg -l | grep php7.4| awk '{print $2}' |tr "\n" " "`

When you run above commands it will prompt you to accept the changes to your system, so type Y to continue. When you are done, PHP-8.0 FPM should be enabled and PHP 7.4-FPM is completely removed from Ubuntu.

Note:- If you are running PHP 7.3 or previous versions on Ubuntu, then replace 7.4 with your specific PHP version to it remove from Ubuntu.

That’s All!

If you find any error and issue in above steps , please use comment box below to report.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top