members
Raspberry basics: Project 17a Raspberry PI 3 model B board - phpLiteAdmin
of Lex C. in Raspberry Pi 3
Raspberry basics: Project 17a
Project name: Raspberry PI 3 model B board - phpLiteAdmin
Tags: Raspberry, Raspberry PI 3 model B board, phpLiteAdmin, Database, SQlite, PHP, Apache2
In this project, you need these parts :
1.Raspberry PI 3 model B 1 pc
2. Micro SD card and SD card adapter 1 pc
3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc
4. USB keyboard 1 pc
5. USB mouse 1 pc
6. TV or PC monitor 1 pc
General
We will learn how to install phpLiteAdmin, a web-based user interface written in PHP that makes it easy to interact with SQLite databases, on Raspberry PI 3 model B board.
You need the Raspbian OS installed on your Raspberry PI 3 model B board.
Understanding the Raspberry PI 3 model B
The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.
Specification:
- Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
- 1GB RAM
- BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
- 40-pin extended GPIO
- 4 USB 2 ports
- 4 Pole stereo output and composite video port
- Full size HDMI
- CSI camera port for connecting a Raspberry Pi camera
- DSI display port for connecting a Raspberry Pi touchscreen display
- Micro SD port for loading your operating system and storing data
- Upgraded switched Micro USB power source up to 2.5A
Signals and connections of the Raspberry PI 3 model B
Step by Step instruction
We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.
1. Setup and preparation
We assume that you have Windows 10 installed on your PC and Raspbian OS installed on your Raspberry PI 3 board.
- Insert your micro SD card with Raspbian OS to Raspberry Pi 3 board.
- Connect the TV or PC monitor Display port (HDMI Port) to your Raspberry PI 3 board HDMI Port (HDMI cable required).
- Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1, etc).
- Plug in your USB mouse and USB keyboard to Raspberry PI 3 board USB ports.
- Get connected. Connect an Ethernet cable to 10/100 LAN port of Raspberry Pi 3 or plug in WiFi adapter (see the list of supported here) to USB port of Raspberry Pi 3.
- Connect Micro USB power supply to Raspberry PI 3 board micro USB input.
- The Raspberry PI desktop will start up.
- Open Terminal window and type the command: sudo apt-get update
- Then type the command: sudo apt-get install
2. Install SQlite on your Raspberry PI 3.
3. Installing Apache2 and PHP
- We need to install Apache2 on the Raspberry PI 3. Apache2 used to serve your web pages. Enter the command: sudo apt-get install apache2 -y
- We also need to install PHP which is an open source web scripting language that is used to build dynamic web applications. Type the command to install PHP and its modules: sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-sqlite -y
-
type the command: sudo apt-get updateThen type the command: sudo apt-get installType the command: sudo apt-get update
- Then type the command: sudo apt-get install
- Go to your /var/www/html directory and edit the dir.conf file by typing these commands:
- cd /var/www/html
- sudo nano /etc/apache2/mods-enabled/dir.conf
- Make the change to the file. Before index.html was first in line. We need to have index.php first in the line.
- Press Ctrl+X buttons, press Y button and press Enter button to save your changes. Restart Apache2 service for the changes to take effect by typing this command: sudo service apache2 restart
4. Testing installation
- Create a new PHP file with the name index.php:
- Copy the next line to your index.php file:
- Press Ctrl+X buttons, press Y button and press Enter button to save your changes.
- Type the command to find your Raspberry Pi IP address: ifconfig
- As you can see we have 192.168.0.121. Go to any web browser (for example, Internet Explorer, Google Chrome, Microsoft Edge) and type your Raspberry PI IP address: http://your_rasberry_pi_IP_address (we have http://192.168.0.121)
- You should see the page like that:
- Congrats!!! Your PHP installation is successful. We can remove the index.php file now by typing this command: sudo rm index.php
5. Installing phpLiteAdmin
- Create a new folder called database and go to it by typing these commands:
- sudo mkdir database
- cd database/
- Type these commands 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 type these commands:
- sudo cp phpliteadmin.config.sample.php phpliteadmin.config.php
- sudo nano phpliteadmin.config.php
- Type a unique password.
- Press Ctrl+X buttons, press Y button and press Enter button to save your changes.
6. Changing file and folder permissions
- In order to make phpLiteAdmin work properly you need to change some permissions and files ownership. Type these commands:
- cd ..
- sudo chmod 777 database
- sudo chmod 777 database/*
- sudo chown root:root database
- sudo chown root:root database/*
- We need to confirm that root is the owner and those are the permissions for the database folder, type the command: ls -l
7. Testing phpLiteAdmin amd creating a SQL database
- Go to any web browser (for example, Internet Explorer, Google Chrome, Microsoft Edge) and type your Raspberry PI IP address: http://your_rasberry_pi_IP_address/database/phpliteadmin.php (we have http://192.168.0.121/database/phpliteadmin.php)
- You should see the page like that:
- Enter your password to login. You will see another web page:
- Enter name of your database (for example sensorsvalues.db) into Create new database field and press Create button.
- Create new table. Type Name dhtreadings and Number of Fields 6 and press Go button.
- Enter the data in the fields. See the example below:
- Press Create button.
- Open the Structure tab. You can see the settings of each column and you can change them if necessary.
- Right now the table has 6 columns but do not have any rows. To add rows go to the Insert tab and add rows 1 and 2.
- Go to the Browse tab now. Inside that table you can see two rows:
- Click on sensorvalues.db in the Change database field if you want to add new table in the database. Go to the Create new table field, enter Name, Number of fields and press Go button.
- You can also Rename or Delete database if you select Rename database tab or Delete database tab.
- As you can see it more easy to use phpLiteAdmin then send SQL commands through a terminal window. You can add, remove, update all data through a simple user interface.
Summary
We have learnt how to install phpLiteAdmin, a web-based user interface written in PHP that makes it easy to interact with SQLite databases, on Raspberry PI 3 model B board.
Library
- No libraries needed in this project
Sketch
- No sketches needed in this project
Other projects of Lex C.








jobs.viewed