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 scripting language that is commonly used to develop web applications. It can be used to create dynamic websites that will adapt pages to a specific user. Its advantages are its wide range of capabilities and security due to its closed source code.
In this guide we will install PHP 8.3 version on Ubuntu (starting from 20.04 version). You can also use this tutorial for any other PHP version.
Update your system by running this command:
apt update
To access the latest PHP versions, add the Ondřej Surý PPA to your system by running:
apt install software-properties-common -y
add-apt-repository ppa:ondrej/php
Then repeat the system update:
apt update
Run this command to install PHP (You can also install any other version by simply entering a different number in place of 8.3.):
apt install php8.3
Please note that on some systems, the second update command or the installation of PHP 8.3 may automatically install Apache. If you do not require it, you can run the following commands to remove Apache:
systemctl stop apache2
apt remove apache2 -y
apt purge apache2 -y
apt autoremove -y
If you wish to keep it, simply continue following this guide.
Most web applications need extra PHP extensions. You can install common PHP extensions by running command (change version number if you using a different one):
apt install php8.3-cli php8.3-fpm php8.3-mysql php8.3-curl php8.3-xml php8.3-zip php8.3-mbstring php8.3-gd php8.3-soap php8.3-intl php8.3-bcmath
If you have Apache running, execute the following commands to enable the PHP-FPM extension:
a2enmod proxy_fcgi setenvif
systemctl restart apache2
a2enconf php8.3-fpm
systemctl reload apache2
To verify if PHP was installed correctly, you can execute this command, which will display information about the installed version:
php -v
To display all available PHP extensions, use the following command:
php -m
To install any PHP extension manually, run this command (replace extension_name and version if you are using a different one)
apt install php8.3-extension_name -y