How to install phpLiteAdmin Database

In this post I will  introduce you to phpLiteAdmin which is a web-based user interface written in PHP that makes it easy to interact with SQLite databases.

Basic Raspberry Pi setup

Before you continue reading this project, make sure you have Raspbian Operating System installed in your Raspberry Pi.

Installing SQLite

You also need to have SQLite installed in your Raspberry Pi.

Installing Apache2 and PHP

You need to install Apache2 in your Raspberry, Apache is used to serve your web pages. Enter the next command:
sudo apt-get install apache2 -y
You also need to install PHP which is an open source web scripting language that is used to build dynamic web applications. To install PHP and its modules, type in this command:
sudo apt-get install php5 libapache2-mod-php5 php5-sqlite -y
Move to your /var/www/html directory and edit the dir.conf file:
cd /var/www/html
sudo nano /etc/apache2/mods-enabled/dir.conf

Make the next change to the file. Before: index.html index.php

After: index.php index.html

Ctrl+X, type Y and press Enter to save your changes. Restart Apache2 service for the changes to take effect:
sudo service apache2 restart

Testing your installation

Create a new PHP file with the name index.php:
sudo nano index.php
Copy the next line to your index.php file:

Ctrl+X, type Y and press Enter to save your changes.

Go to your Raspberry Pi IP address (use the command ifconfig to print your Pi IP address in your terminal window) and this is what you should see:

Your PHP installation was successful. Now, you can remove the index.php file:
sudo rm index.php

Installing phpLiteAdmin

While on the /var/www/html directory, create a new folder called database:
sudo mkdir database
cd database/

Follow the next command to download and prepare phpLiteAdmin:
sudo wget https://bitbucket.org/phpliteadmin/public/downloads/phpLiteAdmin_v1-9-7-1.zip
sudo unzip phpLiteAdmin_v1-9-7-1.zip
sudo rm phpLiteAdmin_v1-9-7-1.zip

To set a password and the path to your SQLite database in your phpLiteAdmin configuration, this is what you need to do:
sudo cp phpliteadmin.config.sample.php phpliteadmin.config.php
sudo nano phpliteadmin.config.php

Change your file to look similar to mine (see below). Type a unique password and the path to your SQLite database:

Create a SQLite database file

You can use the file created in the previous tutorial or simply create a new one:
sqlite3 sensordata.db
sqlite> .quit

Changing file and folder permissions

In order to make phpLiteAdmin work properly you need to change some permissions and files ownership. Run the following commands:
cd ..
sudo chmod 777 database
sudo chmod 777 database/*
sudo chown root:root database
sudo chown root:root database/*

After running the preceding commands, confirm that root is the owner and those are the permissions for the database folder:
ls -l
drwxrwxrwx 2 root root 4096 Jan 30 15:11 database

Testing phpLiteAdmin

Open your http://RPi_IP_Address/database/phpliteadmin.php. This is how it should look like:

Enter your password to login and this is the web page that loads:

On the left menu, you can see your database and table (if you’ve used the database created in the previous SQLite tutorial). Open the dhtreadings table:

Inside that table you can see two rows:

Open the Structure tab:

You can see the settings of each column and you can change them if necessary.

Next, open the sensordata database:


Select the Create new table option and give it a name, for example outputs:

Then, you could define the data columns for each row:

Wrapping up

The real advantage of using phpLiteAdmin is: instead of sending SQL commands through a terminal window, you can add, remove, update all data through a nice user interface.

We’ve just scratched the surface of what you can do with SQLite.

Short URL: http://tinyurl.com/yd3ur6ko
www.pdf24.org    Send article as PDF   

1 thought on “How to install phpLiteAdmin Database”

Mai Mariarti

That was a nice one.
Please change references to php5 as it’s no longer available on Raspberry Pi.
I spent an hour googling stuff to find that out.

php5 –> php7
libapache2-mod-php5 — libapache2-mod-php7
php5-sqlite –> php-sqlite3

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!