Warning: Declaration of Db::query($query) should be compatible with mysqli::query($query, $resultmode = NULL) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 29

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Cannot modify header information - headers already sent by (output started at /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php:0) in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 168

Warning: session_start(): Cannot start session when headers already sent in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 169

Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64
jobs.html_title
4

members

Easy 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.

  1. Insert your micro SD card with Raspbian OS to Raspberry Pi 3 board.
  2. Connect the TV or PC monitor Display port (HDMI Port) to your Raspberry PI 3 board HDMI Port (HDMI cable required).
  3. Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI 1,  etc).
  4. Plug in your USB mouse and USB keyboard to Raspberry PI 3 board USB ports.
  5. 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.
  6. Connect Micro USB power supply to Raspberry PI 3 board micro USB input.
  7. The Raspberry PI desktop will start up.
  8. Open Terminal window and type the command: sudo apt-get update
  9. Then type the command: sudo apt-get install 

2. Install SQlite on your Raspberry PI 3.

3. Installing Apache2 and PHP

  1. 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
  2. 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

  3. type the command: sudo apt-get update
    Then type the command: sudo apt-get install 
    Type the command: sudo apt-get update
  4. Then type the command: sudo apt-get install 

  5. Go to your /var/www/html directory and edit the dir.conf file by typing these commands: 
  6. cd /var/www/html
  7. sudo nano /etc/apache2/mods-enabled/dir.conf

  8. Make the change to the file. Before index.html was first in line. We need to have index.php first in the line.
  9. 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

  1. Create a new PHP file with the name index.php
  2. Copy the next line to your index.php file: 
  3. Press Ctrl+X buttons, press Y button and press Enter button to save your changes.
  4. Type the command to find your Raspberry Pi IP address: ifconfig
  5. 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)
  6. You should see the page like that:
  7. 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

  1. Create a new folder called database and go to it by typing these commands: 
  2. sudo mkdir database
  3. cd database/
  4. Type these commands to download and prepare phpLiteAdmin:
  5. sudo wget https://bitbucket.org/phpliteadmin/public/downloads/phpLiteAdmin_v1-9-7-1.zip
  6. sudo unzip phpLiteAdmin_v1-9-7-1.zip
  7. sudo rm phpLiteAdmin_v1-9-7-1.zip
  8. To set a password and the path to your SQLite database in your phpLiteAdmin configuration type these commands:
  9. sudo cp phpliteadmin.config.sample.php phpliteadmin.config.php
  10. sudo nano phpliteadmin.config.php
  11. Type a unique password.
  12. Press Ctrl+X buttons, press Y button and press Enter button to save your changes.

6. Changing file and folder permissions

  1. In order to make phpLiteAdmin work properly you need to change some permissions and files ownership. Type these commands:
  2. cd ..
  3. sudo chmod 777 database
  4. sudo chmod 777 database/*
  5. sudo chown root:root database
  6. sudo chown root:root database/*
  7. 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

  1. 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)
  2. You should see the page like that:
  3. Enter your password to login. You will see another  web page:
  4. Enter name of your database (for example sensorsvalues.db) into Create new database field and press Create button.
  5. Create new table. Type Name dhtreadings and Number of Fields 6 and press Go button.
  6. Enter the data in the fields. See the example below:
  7. Press Create button.
  8. Open the Structure tab. You can see the settings of each column and you can change them if necessary.
  9. 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.
  10. Go to the Browse tab now. Inside that table you can see two rows:
  11. 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.
  12. You can also Rename or Delete database if you select Rename database tab or Delete database tab.
  13. 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.published_at
jobs.viewed