It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
PHP is a popular programming language used to create dynamic websites and applications. It is widely used in web development due to its simplicity and powerful features. This article will guide you through installing PHP 8.3 on Debian versions 11 and 12.
Update your system by running this command:
apt update
Install the required packages to add a repository:
apt install -y apt-transport-https lsb-release ca-certificates wget
Run the following command to install install GnuPG and import the GPG key for the repository:
apt install -y gnupg
wget -qO - https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/php.gpg
Add the repository to your sources list:
echo "deb https://packages.sury.org/php/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/php.list
Update the system again:
apt update
Run this command to install PHP (to install a different version, just replace 8.3 with the desired version number):
apt install -y php8.3
The installation of PHP 8.3 might automatically install Apache. If you don't need it, you can use these commands to uninstall Apache:
systemctl stop apache2
apt remove apache2 -y
apt purge apache2 -y
apt autoremove -y
Run this command to install common PHP extensions (you can change the version number):
apt install -y php8.3-cli php8.3-fpm php8.3-common php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath php8.3-imap
To manually install PHP extensions, you can run this command (replace extension_name with actual extension name):
apt install php8.3-extension_name
If Apache is running, use these commands to enable the PHP-FPM extension:
a2enmod proxy_fcgi setenvif
systemctl restart apache2
a2enconf php8.3-fpm
systemctl reload apache2
Run this command to check if PHP was installed successfully:
php -v
The output should display information about the installed version:
You also can list all available PHP extensions. Use the following command:
php -m
If you’re using a web server, restart it to apply the changes.
For Apache, run this command:
systemctl restart apache2
For Nginx, run the following command:
systemctl restart php8.3-fpm
systemctl restart nginx