PHP is a powerful web scripting language used to design interactive and dynamic websites. “PHP 8.0” is the latest version of PHP which cannot be installed directly from the local repository on Debian. To install the latest PHP on Debian, an external repository will be required.
This blog is a guide on how to install the latest version of PHP, which is 8.0 on Debian.
Install PHP on a Debian 11
The content of this article is distributed under several headings which are:
Installing PHP
To install the latest PHP version on Debian, follow the below-written steps:
Step 1: First update/upgrade the repository of the system by using the below-mentioned commands:
sudo apt upgrade
After upgrading the repository, it is recommended to reboot the system so that all the upgraded repositories can reload:
Step 2: Now install the required dependencies using the below-written command:
Step 3: The latest version of PHP is available through the website sury.org, to add the sury repository run the below-written command:
Step 4: Also, import the sury repository key by using the below-mentioned wget command:
Step 5: Run the update command to ensure that the repository is added successfully:
Step 6: Once the repository is added successfully then install PHP 8.0 by running the below-written apt command:
Step 7: To verify that the installation of the latest version of PHP is successful run the below-written command:
Modules/Extensions of PHP
After installing the latest PHP version, now if you want to find out all the available extensions/modules of PHP then run the below-written command:
From the above list of PHP modules, if you are interested in installing any of them then follow the below-written syntax:
For example:
One can also install multiple modules at a time as shown below where MySQL, XML and zip modules are installed at a time:
To find the all the installed/loaded modules of PHP, run the below-written command:
PHP Testing
To test the processing of installed PHP, let’s create a new php file using the below-written command:
Then add a text message in it:
Now to execute the created .php file, follow the below-mentioned command:
In the output, you can see that the message text has been displayed successfully, which means php is working successfully on the system;
Conclusion
To install the latest PHP version on Debian, users first need to install some dependencies on the system. After that, they have to add the sury repository and then update the repository using the “update” command. Then, they can install PHP 8.0 from the apt command with the required PHP modules right after the repository update.