Home WebServer PanelaaPanel Change the PHP version on aaPanel

Change the PHP version on aaPanel

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In this tutorial, AZDIGI will help you change the PHP version on the aaPanel system.

I. Introduction

At this point, by default, aaPanel allows us to use multiple versions of PHP simultaneously to configure websites easily. However, when you use the php command via SSH, the default is to use the PHP 7.2 version configured in aaPanel.

For some older systems, PHP version 7.2 may be suitable for this configuration, but now the system has been increasingly developed and updated with many new features, which means that newer PHP versions are constantly being added was launched in response to that. And in aaPanel, the developer has also allowed the use of many newer and latest PHP versions, is PHP 8.1.

And to change the PHP version of the aaPanel system, please continue to read this article.

II. Change the PHP version on aaPanel

To change the PHP version on aaPanel system, we need to do the following 3 steps.

Step 1: SSH into your aaPanel system

To change the PHP version on aaPanel system, we first need to SSH or access your VPS/server with root privileges, or at least access to a user with sudo privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSH, we continue with step 2 to determine the PHP versions you use on your aaPanel server.

Step 2: Determine installed PHP versions

To determine the installed PHP versions, you execute the following command:

AZDIGI Tutorial
ll /www/server/php
    

Here are my results, and you can see you’re using parallel versions:

  • PHP 5.6
  • PHP 7.2
  • PHP 7.3
  • PHP 7.4
  • PHP 8.0
Change the PHP version on aaPanel

In case you only have 1, 2 or 3 versions of PHP, you can install a new version of PHP by following these instructions:

And to determine the PHP version of the system you are using, run the following command:

AZDIGI Tutorial
php -v
    

Below is my system PHP version:

Change the PHP version on aaPanel

Step 3: Change PHP version on system aaPanel

Since you have identified the PHP versions installed on the system, and the version is already the default, you can replace it with another version. For example, I will change the default PHP 7.2 to PHP 8.0, then you can refer to the following 2 methods:

  • Method 1: Change by command via SSH

If you want to change PHP 8.0 as default (Requires your server to have PHP 8.0 already):

AZDIGI Tutorial
rm -f /usr/bin/php
ln -s /www/server/php/80/bin/php /usr/bin/php
php -v
    

This is the result when I switched to PHP 8.0:

Change the PHP version on aaPanel

  • Method 2: Change via the interface aaPanel

If you want to change PHP 7.4 as default (Requires your server to have PHP 7.4 already):

First, you need to log in to aaPanel and go to Website => PHP CLI version => Select the PHP version to change=> Submit.

Change the PHP version on aaPanel

Below is the system PHP version after the change:

Change the PHP version on aaPanel

So we have changed the PHP version on the aaPanel system successfully.

You may wonder why just a few commands above can be changed, right? This is the answer:

Because when you use the command whereis php will locate the source of a command, like here we are looking for the source of php.

Change the PHP version on aaPanel

Then you just need to ll the path /usr/bin/php to learn more.

Change the PHP version on aaPanel

As shown above, actually /usr/bin/php is the symlink of /www/server/php/74/bin/php. And from there, we just need to delete the old symlink and set up the new symlink.

III. Summary

Changing the PHP version on aaPanel system brings quite a lot of benefits, the first one is that phpMyAdmin will run on a newer version of PHP, work smoother, be more stable and more secure. The crontabs you use in php work similarly and are much more stable…

See more useful articles about aaPanel at the following link:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign