How to Upgrade PHP 8.1 to 8.2 on Ubuntu

How to Upgrade PHP 8.1 to 8.2 on Ubuntu

To upgrade to PHP 8.2 from 8.1, Simply add the PHP repository to your system and then use sudo apt install php8.2 command to install php 8.2 and activate it in ubuntu system.

Steps to upgrade the PHP 8.1 to 8.2 version on Linux Ubuntu via the command line:

Step 1: Update System Packages

Press ctrl+alt+t on the keyboard to start a terminal window, and type the sudo apt-get update command in it to update system packages:

sudo apt-get update

Step 2: Add the Latest PHP repository

Add the latest PHP repository to the Ubuntu server by typing the following command in the terminal window and pressing Enter.

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

Step 3: Install PHP 8.2 and Its Packages

To install php 8.2 version, use sudo apt install php8.0 command on Ubuntu terminal window and press Enter:

sudo apt install php8.2

Once you have installed php 8.2 in your Ubuntu system, after this, you also need to install the packages related to PHP 8.2, for this, you can use the following command on the terminal window:

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

Step 4: Activate PHP 8.2 & Deactivate PHP 8.1

Firstly, you need to disable or deactivate php 8.1 version in ubuntu server, type sudo a2dismod php8.1 command on terminal window and press enter:

sudo a2dismod php8.1

To activate or enable php 8.2 on ubuntu, use sudo a2enmod php8.2 command on terminal window and press enter:

sudo a2enmod php8.2

To apply the changes, restart the Apache web server by typing the sudo service apache2 restart command on the terminal window and press Enter:

sudo service apache2 restart

Step 5: Verify PHP Version

Now type the command php -v on the terminal window and press enter and you will see on the terminal window that your php version has been upgraded:

php -v

You have upgraded php 8.1 to 8.2 version but you are still seeing the same old version on terminal window, it means that the changes in the configuration file have not been applied, Simply type the sudo update-alternatives --config php command on the terminal window and press enter, it will do the configuration on your Ubuntu for updated PHP 8.2 version:

sudo update-alternatives --config php

Conclusion

By using these tutorial steps, you can easily update or upgrade php 8.1 to 8.2 on ubuntu via terminal window.

Recommended Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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