Skip to content

Installation

d3noob edited this page Jul 23, 2018 · 33 revisions

Overview

The installation process is based on the presumption that is is carried out on a Raspberry Pi. This is obviously not the only platform that could be used, but at this stage in development, any variation from that will be going beyond what has been tested (Fair warning).

The instructions below should be sufficient to get you running, assuming that you have some basic Linux and computing skills. If you are looking for a deeper description of some of the principles involved, I would shamelessly recommend 'Just Enough Raspberry Pi'.

Pi setup

The starting point should be a Raspberry Pi with a fresh installation of Raspbian loaded. It should also either have a keyboard / monitor connected or have ssh enabled with access from a remote computer (remote access is definitely preferred).

This is a set of very generic setup instructions to get a Raspberry Pi configured for use. The aim is to be able to get the SD card image, write the image to the card with the appropriate information to allow boot and configuration.

Downloading and writing Raspbian

The best place to source the latest version of the Raspbian Operating System is to go to the raspberrypi.org page; http://www.raspberrypi.org/downloads/. Download the 'Lite' version (which doesn't use a desktop GUI). Always try to download image files from the authoritative source!

This guide is written assuming the 'Stretch' version of Raspbian is being sourced, but it is likely that others will follow a similar path.

Load the Operating System image onto the SD card

Download and install Etcher and start it up. Etcher is an excellent piece of software to burn images reliably and simply.

Select the Raspbian img file to install.

Place the card in the reader and you should see Etcher automatically select it for writing (Etcher is very good at presenting options for installing that are only SD cards).

Then click on 'Flash!' to burn the card.

Etcher will write the image to the SD card. The time taken can vary a little, but it should only take about 3-4 minutes with a class 10 SD card.

Once written, Etcher will validate the write process (this can be disabled if desired).

When the process is finished Etcher will automatically unmount the SD card.

We need to configure the card for initial use, so unplug it and plug it back in again to mount it and we will make some adjustments before we put it into the Pi.

Configure the card

Create a new file on the microSD card called ssh. It doesn't matter if the file has no content or has a .txt suffix. This allows ssh to be enabled on first boot.

Once we have ssh access we'll be able to configure our Raspberry Pi Remotely.

If you have the Pi connected to a network via the ethernet connector (hard wired) you should be good to continue. If you need to configure a wireless connection read on./..

To get the Pi to connect to the wireless network create a new file on the SD card (in the same drive) with name of wpa_supplicant.conf and paste the following contents in there (Change ssid and password (psk) according to your own network).

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
 
network={
    ssid="Wombat"
    psk="1212121212"
    key_mgmt=WPA-PSK
}

T> I found the first time that I was editing the file in my text editor of choice in Windows (Geany) it was using new-line characters from Windows. This needs to be changed so that the file uses Unix/Linux new line characters.

wpa_supplicant.conf file will be copied to /etc/wpa_supplicant/ directory on boot and our Pi will be connected to the WiFi network automatically.

Finalize basic setup

Unmount the SD card and install it in the Pi.

Power on and let the device go through the first boot routine which will expand the disk and reboot. Be patient. This may take around 90 seconds or so.

Once done you should be able to ssh into the Pi using `ssh pi@raspberrypi.local' from a terminal program. The default password for the 'pi' user is 'raspberry' (the recommendation is that you should change this).

If you need to determine the IP address of the Pi we can do this by running ping raspberrypi.local -4 (the '-4' forces it to use ip4 rather than ip6 which could get confusing). From the IP you should be able to ssh into the device from a console prompt or shell terminal via ssh pi@<ip-address>.

Carry out the installation

Once you can ssh into the Pi we can download the setup script, asign appropriate permissions and get started;

curl -L -O https://github.com/d3noob/PiMetric/raw/master/setup-pimetric-full.sh
chmod 775 setup-pimetric-full.sh

At this point we need to decide what the domain name of the raspberry pi will be. The default is 'pimetric'. This means that when we go to access the server from a web page, we do so using the address http://pimetric.local/main.php. If you want to change that name to something else, we will need to edit the setup-pimetric-full.sh file with the 'nano' editor...

nano setup-pimetric-full.sh

... and change the name on the line that says;

HOSTNAME="pimetric"

Now we can run the script to get the installation underway.

sudo ./setup-pimetric-full.sh

Then script will take over from this point and complete the installation by doing the following;

  • Update and upgrade the OS
  • Get the PiMetric files from GitHub
  • Unzip the Files
  • Change the name of the directory
  • Change the permissions / ownership of the directory and files
  • Allow the 'www-data' group permission to write to the directory
  • Add the 'pi' user to the 'www-data' group.
  • Give the database the appropriate permissions for access
  • Install the NGINX web server and php
  • Configure NGINX to include php support and change the root location for the web server
  • Restart the NGINX service
  • Install the SQLite database and programs for accessing different metrics
  • Install the Python 3 script modules
  • Add the crontab lines
  • Reboot

We're done

We should now have a functional installation of PiMetric. We should be able to browse to 'http://pimetric.local/read.php' to see the list of metrics currently installed and operating. Likewise we should be able to go to 'http://pimetric.local/main.php' to look at the operational view.

From here you will want to think about adding your own metrics!

Clone this wiki locally