1. Install Apache2, PHP and Sqlite3 in Ubuntu
Updated on March 1, 2026.
Note: The instructions below include php version php8.5 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.5 libapache2-mod-php8.5
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.5-module_name
For example, to install the sqlite3 module enter:
sudo apt install php8.5-sqlite3
To install both the mysql and sqlite3 modules enter:
sudo apt install php8.5-{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.