Cloudbooklet Logo
  • AI
  • ChatGPT
  • MidJourney
  • Linux
Notification
  • AI Tools
  • AI Images
  • Web Stories
Create Image
Cloudbooklet AICloudbooklet AI
  • AI Tools
  • AI Images
  • Web Stories
Search
Generate AI Image

Top Categories

  • AI
  • ChatGPT
  • Midjourney
  • Linux

Top Articles

Snapchat Ai

How To Protect Your Privacy And Security From Snapchat AI

Turn Off Bitmoji Reactions

How to Turn Off Bitmoji Reactions While Viewing Snapchat Stories

Adult Ai Image Generator

5 Best Adult AI Image Generator to Create Adult Images

Follow US
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
Cloudbooklet © 2023 All rights reserved.

Home » Google Cloud » How to Install PHP 8 on Ubuntu 20.04

Google CloudAWS

How to Install PHP 8 on Ubuntu 20.04

Last updated: 2021/04/21 at 1:10 AM
By Cloudbooklet
How To Install Php 8 On Ubuntu
SHARE
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Install PHP 8 on Ubuntu 20.04. This guide let you learn how install the latest PHP version 8 and upgrade to latest on your Ubuntu 20.04 or 18.04 systems or your Ubuntu server on any VPS or any Cloud or any Dedicated hosting and configure it with Apache and Nginx.

The latest PHP 8 is officially released on November 26th, 2020. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.

Table of Contents
PrerequisitesGetting StartedAdd PPA for PHP 8Install PHP 8 for ApacheInstall PHP 8 FPM for NginxInstall PHP 8 ExtensionsConfigure PHP 8 for ApacheConfigure PHP 8 for NginxConfigure PHP 8 FPM Pools – NginxRestart PHP 8.0 FPM – NginxUpgrade to PHP 8 for ApacheUpgrade to PHP 8 for NginxConclusion

This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. This set up will work on all Linux servers.

Prerequisites

  1. A Ubuntu server set up with sudo privileges.
  2. Completed the initial Ubuntu server setup.

If you are using Google Cloud Platform to install PHP you need the following steps to be done.

  1. A running Compute Engine, see the Setting up Compute Engine Instance with Ubuntu 20.04.

Getting Started

Make sure your Ubuntu server is having the latest packages by running the following command.

sudo apt update
sudo apt upgrade

This will update the package index and update the installed packages to the latest version.

Add PPA for PHP 8

Add the ondrej/php which has PHP 8 package and other required PHP extensions.

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

Once you have added the PPA you can install PHP 8.

Install PHP 8 for Apache

Execute the following command to install PHP 8

sudo apt install php8.0

After the installation has completed, you can confirm the installation using the following command

php -v

Install PHP 8 FPM for Nginx

For Nginx you need to install FPM, execute the following command to install PHP 8 FPM

sudo apt install php8.0-fpm

After the installation has completed, confirm that PHP 8 FPM has installed correctly with this command

php-fpm8.0 -v

Install PHP 8 Extensions

Installing PHP extensions are simple with the following syntax.

sudo apt install php8.0-extension_name

Now, install some commonly used php-extensions with the following command.

sudo apt install php8.0-common php8.0-mysql php8.0-xml php8.0-curl php8.0-gd php8.0-imagick php8.0-cli php8.0-dev php8.0-imap php8.0-mbstring php8.0-opcache php8.0-soap php8.0-zip -y

Configure PHP 8 for Apache

Now we configure PHP for Web Applications by changing some values in php.ini file.

For PHP 8 with Apache the php.ini location will be in following directory.

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

Hit F6 for search inside the editor and update the following values for better performance.

upload_max_filesize = 32M 
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

Once you have modified your PHP settings you need to restart your Apache for the changes to take effect.

Configure PHP 8 for Nginx

For PHP 8 FPM with Nginx the php.ini location will be in following directory.

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

Hit F6 for search inside the editor and update the following values for better performance.

upload_max_filesize = 32M 
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000

Once you have modified your PHP settings you need to restart PHP FPM for the changes to take effect.

sudo php-fpm8.0 -t 
sudo service php8.0-fpm restart

Configure PHP 8 FPM Pools – Nginx

PHP 8 FPM allows you to configure the user and group that the service will run under. You can modify these with these commands

sudo nano /etc/php/8.0/fpm/pool.d/www.conf

Change the following lines by replacing the www-data with your username.

user = username 
group = username 
listen.owner = username
listen.group = username

Hit CTRL+X and Y to save the configuration and check if the configuration is correct and restart PHP.

Restart PHP 8.0 FPM – Nginx

Once you have updated your PHP FPM settings you need to restart it to apply the changes.

sudo php-fpm8.0 -t 
sudo service php8.0-fpm restart

Now you are having PHP 8 Installed and configured.

Prepare yourself for a role working as an Information Technology Professional with Linux operating system

Upgrade to PHP 8 for Apache

Once you have installed PHP 8 you need to upgrade to the latest installed version of PHP.

You need to disable the old PHP version and enable the new PHP version 8.

sudo a2dismod php7.4 

This command will disable the PHP 7.4 module.

sudo a2enmod php8.0

This command will enable the PHP 8 module.

Now you need to restart Apache for the changes to take effect.

sudo service apache2 restart

Upgrade to PHP 8 for Nginx

For Nginx you need to update the PHP-FPM socket in your Nginx configuration located inside the sites-available directory. This will be located inside the location block location ~ \.php$

Edit your configuration…

sudo nano /etc/nginx/sites-available/your.conf

The line you need to modify will look like this…

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

You need to replace the old PHP version with the new version.

fastcgi_pass unix:/run/php/php8.0-fpm.sock;

Test your configuration and restart Nginx.

sudo nginx -t
sudo service nginx restart

Conclusion

Now you have learned how to install PHP 8 and upgrade your configuration on your Ubuntu server.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

TAGGED: PHP, Ubuntu, Ubuntu 18.04, Ubuntu 20.04
Share This Article
Facebook Twitter Whatsapp Whatsapp LinkedIn Reddit Telegram Copy Link Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
3 Reviews 3 Reviews
  • Avatar Of Taranetarane says:

    thank you so… much

    Reply
  • Avatar Of Raja99Raja99 says:

    Thanks! I’ve bought you a coffee 😉

    Things have moved quickly; I didn’t have to add the ondrej/php PPA.

    One slight suggestion: It wasn’t clear to me whether the sections titled “Configure PHP 8 FPM Pools” and “Restart PHP 8.0 FPM” were Nginx-only. Since I’m using Apache2, I skipped them, but wondered if that was why I had trouble with Apache2 sticking with PHP7.4 even after multiple “sudo a2dismod php7.4” and apache restarts. (I fixed the problem by finding guidance elsewhere on how to completely remove PHP7.x from my system.) Perhaps everybody else already knows that FPM is Nginx-only.

    Reply
    • Avatar Of CloudbookletCloudbooklet says:

      Hi thank you so much for the coffee.

      Thank you so much for the suggestion. I will update the heading and let everyone know that the mentioned steps are for Nginx only

      Reply

Leave a review Cancel reply

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

Please select a rating!

Popular

Kobold Ai Safe
Is kobold AI Safe to Use?
Artificial Intelligence
Ai Porn Generator
14 Best Free AI Porn Generators Online 2023
NSFW
Tiktok Asking For Passcode
Why Does TikTok Asking for Passcode: How to Bypass It
Artificial Intelligence
Beeper Mini
Apple Cracks Down on Beeper Mini: No More iMessage for Android Users
Artificial Intelligence
- Advertisement -

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Related Articles

Some of the articles related to the one you read above.
Ubuntu Password
Linux

Reset your Forgotten Ubuntu Password in 2 Minutes

Install Iptables On Ubuntu
Linux

How to Install Iptables on Linux

Open Port In Linux
Linux

How to Open Port in Linux: Simple Step-by-Step Guide

Openai Reverse Proxy With Nginx
Artificial IntelligenceLinux

How to Setup OpenAI Reverse Proxy with Nginx

Cloudbooklet Logo
  • Categories:
  • Artificial Intelligence
  • Applications
  • Google Cloud

Quick Links

  • About
  • Contact
  • Disclaimer
  • Privacy Policy
Cloudbooklet © 2024 All rights reserved.
Welcome Back!

Sign in to your account

Lost your password?