Israel Science and Technology Directory

Apache web server Installing Apache2, PHP and Sqlite3 in Ubuntu

Date updated: February 6, 2025

Note: The instructions below include the latest 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

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.

Next step: Configuring Apache2 server on Ubuntu