1. Install Apache2, PHP and Sqlite3 in Ubuntu
Updated on December 19, 2025.
Note: The instructions below include php version php8.4 that has been updated for Unicode version 16.
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.4 libapache2-mod-php8.4
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.4-module_name
For example, to install the sqlite3 module enter:
sudo apt install php8.4-sqlite3
To install both the mysql and sqlite3 modules enter:
sudo apt install php8.4-{mysql,sqlite3}
To reload these new definitions, stop the server.
sudo service apache2 stop
Restart the server.
sudo service apache2 restart
Entering http://localhost/ in a browser should show the default opening page (index.html) for the Apache2 server.