SQLite is a very popular & fast relational database that is designed to be embedded within software applications. If your server does not already have the SQLite drivers for PHP, please follow the guide below:

If you are using a cPanel based server, follow this guide.

Step 1 - Install SQLite3 on your Linux server

First login to your server via SSH and update your package list:

sudo apt update

Now install SQLite:

sudo apt install sqlite3

To verify the installation, check the software’s version:

sqlite3 --version

You should see an output like this:

3.37.0 2021-12-09 01:34:53 9ff244ce0739f8ee52a3e9671adb4ee54c83c640b02e3f9d185fd2f9a179aapl

Step 2 – Install the pdo_sqlite module for your PHP version

sudo apt-get install php-sqlite3

If the above command does not work, you can try the PHP version-specific instructions below:

For PHP5.x, use sudo apt-get install php5-sqlite
For PHP7.0, use sudo apt-get install php7.0-sqlite
For PHP7.1, use sudo apt-get install php7.1-sqlite
For PHP7.2, use sudo apt-get install php7.2-sqlite
For PHP7.3, use sudo apt-get install php7.3-sqlite
For PHP7.4, use sudo apt-get install php7.4-sqlite
For other PHP versions, use sudo apt-get install phpX.Y-sqlite after replacing X.Y with your PHP version number

Step 2 – Restart Apache/Nginx

To enable these modules for PDO usage, we will have to restart Apache/Nginx on the server.

Restart Apache - sudo service apache2 restart
Restart Nginx - sudo service nginx restart

Step 3 – Verify that module

To test that everything is working fine:

Create a phpinfo file on your server
In the contents of the phpinfo file, search the contents of this file for the string “pdo_sqlite”
If you find a section titled “pdo_sqlite”, it is confirmed that pdo_sqlite & SQLite have been installed
Once the verification is complete delete this file
Was this article helpful?
Thank you!