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

Upgrade WordPress to PHP 8.0 on Ubuntu 20.0418.04 With Apache2

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 Apache2

Ubuntu do not have PHP 8.0 packages in it’s default repositories. So for install PHP 8.0 on Ubuntu for support WordPress, you need to run the below commands to add a third party repository.

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

After add the third party repository above, we need to update and install to PHP 8.0

sudo apt update

After update and install, Next run the below commands to install PHP 8.0 and it’s related modules.

sudo apt install php8.0 libapache2-mod-php8.0 php8.0-common php8.0-mysql php8.0-gmp php8.0-curl php8.0-mbstring php78.0-xmlrpc php8.0-gd php8.0-xml php8.0-cli php8.0-zip

Now, run the below commands to open PHP configuration file for Apache server.

sudo nano /etc/php/8.0/apache2/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 the below commands to disable PHP 7.4.

sudo a2dismod php7.4

Now PHP 7.4 is disabled, so run the below commands to enable PHP 8.0.

sudo a2enmod php8.0

Run the below commands to restart Apache2 and PHP 8.0.

sudo systemctl restart apache2.service

And at the last, run the below commands to remove all PHP 7.4 packages.

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

That’s all!

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