Israel Science and Technology Directory

InternetApache server

Installing PHP 8.2, Apache2 and Sqlite3 in Linux Mint 21.3

This page is intended for people who want to install PHP 8.2 with Sqlite3 database under Linux Mint version 21.3.

See previous version of this file for installing php8.1.

The installation of PHP 8.2 includes also Apache2 server module.

1: Install PHP 8.2

Run the following command in a Terminal window to add the source to your PPA (Personal Package Archive, list of Linux repositories in your computer):

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 -y

Install PHP together with the Apache2 module by running the following:

sudo apt install php8.2 libapache2-mod-php8.2

2: Check the list of all PHP modules installed by entering:

php --modules

If the module you need does not appear on the list, install it by entering:

sudo apt install php8.2-module_name

For example, to install the sqlite3 module enter:

sudo apt install php8.2-sqlite3

To install both the mysql and sqlite3 modules enter:

sudo apt install php8.2-{mysql,sqlite3}

3: Define the default location of the website for your Apache2 server

In the Apache server, the default directory of the website is:

/var/www/html

If you wish to change this location, edit the Apache configuration file by calling xed editor in a terminal window.

sudo xed /etc/apache2/sites-available/000-default.conf

Add a hash (#) sign at the beginning of the following line to mark it as a comment:

DocumentRoot /var/www/html

Add the following line after the commented out line:

DocumentRoot /The-location-of-your-website

Save the file and exit.

Edit Apache configuration file:

sudo xed /etc/apache2/apache2.conf

Towards the end of this file there is a series of lines with the following format:

<Directory ...>
.
.
.
</Directory>

To add the location of your website directory, add the following at the end of the list:

<Directory /The-location-of-your-website>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

# Specify the default file name(s) to load, in the example below "index.htm index.html".  
DirectoryIndex index.htm index.html

To reload these new definitions, stop the server.

sudo service apache2 stop

Restart the server.

sudo service apache2 restart

Finally, open a browser window and call http://localhost/ to see if the website is visible.