Date updated: December 4, 2024
Run the following command in a Terminal window to add the source to the PPA (Personal Package Archive, list of repositories in your server):
sudo add-apt-repository ppa:ondrej/php -y
Update and upgrade your repositories by running the following commands in a terminal window:
sudo apt update && sudo apt upgrade
Install PHP together with the Apache2 module by running the following:
sudo apt install php8.3 libapache2-mod-php8.3
Check the list of all PHP modules installed
php --modules
If a module you need does not appear on the list, install it by entering:
sudo apt install php8.3-module_name
For example, to install the sqlite3 module enter:
sudo apt install php8.3-sqlite3
To install both the mysql and sqlite3 modules enter:
sudo apt install php8.3-{mysql,sqlite3}
To reload these new definitions, stop the server.
sudo service apache2 stop
Restart the server.
sudo service apache2 restart
In a browser entering the domain name (http://www.example.com) or the domain IP should show the default page for the DocumentRoot /etc/apache2/html
. The default page for Apache2 is index.html.