Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Google Cloud

How to Upgrade PHP Version to PHP 8.0 on Ubuntu

by Cloudbooklet
2 years ago
in Google Cloud, Linux
Upgrade Php Version To 8.0
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Upgrade PHP version to PHP 8.0 on Ubuntu. You can upgrade your current PHP version to the latest release PHP 8.0 on your Ubuntu. This upgrade is tested on virtual machine instance running Ubuntu 20.04 OS on Google Cloud Compute Engine. So the steps mentioned in this guide works on any cloud servers like AWS, DigitalOcean, […]

ADVERTISEMENT

Upgrade PHP version to PHP 8.0 on Ubuntu. You can upgrade your current PHP version to the latest release PHP 8.0 on your Ubuntu.

This upgrade is tested on virtual machine instance running Ubuntu 20.04 OS on Google Cloud Compute Engine. So the steps mentioned in this guide works on any cloud servers like AWS, DigitalOcean, Linode, Vultr or any VPS or Dedicated servers running Ubuntu OS.

Here is a brief guide to show you how to install and upgrade to PHP 8.0 on Ubuntu LTS with Apache and PHP8.0-fpm with Nginx.

ADVERTISEMENT

Add PPA for PHP 8.0

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

You might also like

&Quot; Systemd Service On Linux

How to Create a New systemd Service on Linux: A Step-by-Step Guide

3 months ago
List Groups In Linux

How to List Groups in Linux: A Guide for Beginners

3 months ago
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.0.

Install PHP 8.0 for Apache

Execute the following command to install PHP 8.0

ADVERTISEMENT
sudo apt install php8.0

Install PHP 8.0 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.

ADVERTISEMENT
sudo apt install php8.0-common php8.0-mysql php8.0-xml php8.0-xmlrpc 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 php8.0-intl -y

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

php -v

Enable PHP 8.0 for Apache

Now you need to tell Apache to use the installed version of PHP 8.0 by disabling the old PHP module (below I have mentioned php7.4, you need to use your current php version used by Apache) and enabling the new PHP module using the following command.

ADVERTISEMENT
sudo a2dismod php7.4
sudo a2enmod php8.0

Restart Apache for the changes to take effect.

sudo service apache2 restart

Install PHP 8.0 FPM for Nginx

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

ADVERTISEMENT
sudo apt install php8.0-fpm

Follow the same method above mentioned to install the extensions

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

php-fpm8.0 -v

Modify Nginx configuration to use PHP 8.0

For Nginx you need to update the PHP-FPM socket in your Nginx configration 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 configration.

sudo nginx -t

Save the file and exit the editor and restart Nginx for the changes to take effect.

sudo service nginx restart

Configure PHP 8.0

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

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

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

For PHP 8.0 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 your Apache for the changes to take effect.

Configure PHP 8.0 FPM Pools

PHP 8.0 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

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

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

Conclusion

Now you have learned how to upgrade PHP to PHP 8.0 on Ubuntu and configure settings for Apache and PHP-FPM for Nginx.

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

Tags: PHPUbuntu
Share20Tweet13SendShare
Cloudbooklet

Cloudbooklet

Comments 5

  1. Avatar Of Amit Amit says:
    4 months ago

    Very helpfull article

    Thank you!

    Reply
  2. Avatar Of Yervand Yervand says:
    2 years ago

    Thank You very much! Very helpful!

    Reply
  3. Avatar Of Aharown aharown says:
    2 years ago

    This is helpful, thanks!
    One question: why change the user and group the service runs under?

    Reply
    • Avatar Of Cloudbooklet Cloudbooklet says:
      2 years ago

      Changing user and group are optional. Some one may need in certain circumstances.

      Reply
  4. Avatar Of Salman Salman says:
    2 years ago

    Thank you!

    Reply

Leave a Reply Cancel reply

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

Related Posts

Hostname In Linux

How to Modify the Hostname in Linux

3 months ago
Linux Systems

Linux systems Hacked with OpenSSH Malware

3 months ago
Install Iptables On Ubuntu

How to Install Iptables on Linux

3 months ago
Open Port In Linux

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

3 months ago

Follow Us

Trending Articles

Ai Soulmate

5 Free AI Soulmate Maker: Create Your Perfect Match

September 18, 2023

AI Annotation Jobs: Everything You Need to Know

10 Best AI Prompts for Writers to Improve Website SEO

Validator AI: The AI Powered Business Idea Validator

Create High Quality AI Cover Song with Covers AI

7 Best AI Girl Generators for Creating Realistic and Beautiful AI Girls

Popular Articles

Free Business Email Account

10 Free Business Email Account Providers in 2023

August 31, 2023

How to Use WhatsApp Pi – Personal AI Assistant for WhatsApp

Best 10 AI Comic Generator: Create Comic book in Seconds

How Adobe Express AI Can Boost Your Creativity and Productivity

Microsoft Designer: AI Design Tool Now Available in Edge

10 Apps to See Who Viewed Your Instagram Profile

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.