PHP is a widely-used open-source scripting language especially suited for web development. The latest version, PHP 8.3, brings numerous enhancements and features that make it a valuable upgrade for developers. This blog post will guide you through the process of installing PHP 8.3 on Debian 12 Linux systems.
Prerequisites
Before you begin, ensure you have the following:
- A running Debian 12 system
- A user account with sudo privileges
- Internet connectivity to download packages
Step 1: Update the System
Start by updating the package list to ensure you have the latest information on the newest versions of packages and their dependencies.
$ sudo apt update
$ sudo apt upgrade -y
Step 2: Install Required Dependencies
Install necessary packages that will help in adding the repository and fetching PHP 8.3.
bashCopy codesudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
$ sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
Step 3: Add the PHP Repository
To get PHP 8.3, you need to add the Sury PHP repository, which is maintained by Ondřej Surý, a Debian developer.
$ sudo wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
$ sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
Step 4: Install PHP 8.3
After adding the repository, update the package list again and install PHP 8.3.
$ sudo apt update
$ sudo apt install -y php8.3
Step 5: Verify the Installation
To confirm that PHP 8.3 is installed correctly, check its version. This command will display the installed version of PHP.
$ php -v
You should see an output similar to the following, indicating PHP 8.3 is installed:
PHP 8.3.0 (cli) (built: Nov 29 2023 12:34:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
Step 6: Install Additional PHP Modules
Depending on your web application requirements, you might need additional PHP modules. You can install them using the following command pattern:
$ sudo apt install php8.3-<module>
For example, to install common modules, you can run:
$ sudo apt install -y php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-curl php8.3-gd php8.3-mbstring
Step 7: Configure PHP (Optional)
You may want to tweak the PHP configuration to suit your needs. The configuration files are typically located in /etc/php/8.3/cli
and /etc/php/8.3/fpm
. You can edit these files using a text editor like nano
:
$ sudo nano /etc/php/8.3/fpm/php.ini
Make your desired changes, save the file, and restart the PHP-FPM service if necessary:
$ sudo systemctl restart php8.3-fpm
Conclusion
You have successfully installed PHP 8.3 on your Debian 12 system. With PHP 8.3, you can take advantage of the latest features and improvements for your web development projects. For more information on using PHP, refer to the official PHP documentation.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.