# Raspbian on Raspberry pi 3B

This guide is to create a working Open enventory running on OS Raspbian on a Raspberry pi 3B (see <https://www.raspberrypi.org/products/raspberry-pi-3-model-b/> for information on the RPi 3B)

* Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
* 1GB RAM
* Using [SanDisk Ultra 64GB UHS-I/Class 10 Micro SDXC Memory Card](https://www.amazon.com/gp/product/B00M55C1I2/ref=ppx_yo_dt_b_asin_title_o01_s02?ie=UTF8\&psc=1) as boot and home drive&#x20;

Initial Setup

1. Flash a fresh copy of Raspbian onto the micro SD card. (A guide for completing this task can be found here <https://www.raspberrypi.org/documentation/installation/installing-images/>.&#x20;

* Raspbian image found at <https://www.raspberrypi.org/software/operating-systems/> We used "[Raspberry Pi OS with desktop and recommended software](https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-full.zip)" zip file
* use zip file with [balenaetcher ](https://www.balena.io/etcher/)to flash to micro SD&#x20;

2\. Once flashed insert micro SD into the RPi 3B and boot the device with monitor connected. If install completed you should now see the Raspbian desktop as shown below.  &#x20;

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIhj83MwOjB95xWXDG%2F-LxIiSkrho6Ib6TLDHcG%2Fraspbian.PNG?alt=media\&token=8238125d-0fc2-4f1c-8c6d-c1f522b0d9fd)

3\. The first thing that should be done is to update the OS

* open a terminal window by clicking on terminal icon on top bar or by pressing ctl+alt+t
* run the following commands

```
sudo apt-get update
sudo apt-get upgrade
```

4\. After the update has completed we will create a LAMP server on the pi. This was completed following this guide (<https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress>)

* Complete the steps to set up the Apache server, install PHP, and install MYSQL mysql is outdated trying the command in the above link will give you an error use the following instead to setup the mariadb and mysql (NOTE: Wordpress does not need to be installed)

```bash
 sudo apt-get install mariadb-server-10.0
```

5\. Install the following packages to prepare for Open enventory

```bash
sudo apt-get install -y php-mysql php-gd php-mbstring php-pear ghostscript imagemagick
sudo service apache2 restart
```

6\. Create MYSQL root pwd by entering the following command in terminal the default password is blank. We will subsequently set it up so sudo is not required so that we can login online to create our databases for oe. When asked for a password after command 4, use the password we just set up for `mysql_secure_installation`.

```bash
sudo mysql_secure_installation 
sudo service apache2 restart
sudo service mariadb restart
sudo mysql -u root -p
MariaDB [(none)]> USE mysql;
MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
MariaDB [mysql]> FLUSH PRIVILEGES;
MariaDB [mysql]> exit;
sudo service mariadb restart
```

7\. Download Open Enventory image and set up on apache server (exact link to download can be found at <https://sourceforge.net/projects/enventory/files/?source=navbar>) (NOTE: in terminal commands below, the `open_enventory_2019-07-24.zip`should be replaced with the version you wish to use)\
&#x20;    \- Once downloaded unzip and copy to the right location which we will need to make.

```bash
cd ~/Downloads/
wget https://sourceforge.net/projects/enventory/files/open_enventory_2019-07-24.zip
unzip open_enventory_2019-07-24.zip
sudo mkdir /var/www/html/oe
sudo cp -r ~/Downloads/open_enventory_2019-07-24/. /var/www/html/oe
```

8\. Now go to the <http://xx.xx.xx.xx/oe>

{% hint style="info" %}
With xx.xx.xx.xx: is the server’s ip address
{% endhint %}

To find the ip address of your raspberry pi on your local network run the following command. The result will yield many things we only care about the ip address number directly following `inet`

```bash
ifconfig
```

going to servers address in a browser on a device on the local network will look like the following

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIriQ086Zfm3W_WoFk%2F-LxIujch5G_j9fzEBmX_%2Fimage.png?alt=media\&token=5afb028a-0ec8-407b-9663-0092b1bfd01f)

{% hint style="info" %}

* Database: to create a new database, type the desired database’s name
* Username: root
* Password: use the mariadb password that was set up in step 6 of this tutorial
  {% endhint %}

9\. If successful after clicking inventory you should see the following page

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIriQ086Zfm3W_WoFk%2F-LxIvM694PnWnI_LclAQ%2Fimage.png?alt=media\&token=c37154e7-6472-43d4-b34c-233a86c4754b)

10\. Modify .htaccess file

```bash
sudo nano /var/www/html/oe/.htaccess
```

Modify the content of the file as in this screenshot. Important: these settings are for the server with configuration as indicated in the top of this tutorial

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIriQ086Zfm3W_WoFk%2F-LxIw0rT3bs9c7t6WmE_%2Fimage.png?alt=media\&token=4c447eb5-2d28-43a8-8cbd-31afbeb8b29a)

Save the file by typing ctrl+o then hitting the enter key then exit by typing ctrl+x. You will then have to tell the raspberry pi to use the settings in the .htaccess file. Navigate to 000-default.conf and add add the Directory lines so that the file is identical to the image below.

```bash
sudo nano /etc/apache2/sites-available/000-default.conf
```

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIriQ086Zfm3W_WoFk%2F-LxIz-tuA0iqE0V16AYC%2Fimage.png?alt=media\&token=a8ff3a66-6548-483e-bc1c-94ff1b43fe69)

Then restart the apache server

```bash
sudo service apache2 restart
```

{% hint style="success" %}
You are done with the initial set up here. Open Enventory is ready to be used at this time.
{% endhint %}

11\. Note this can only be accessed on the local server if you wish to access the OE database on any network you can set up ngrok. If you sign up you can use the given link indefinitely, and using <https://freedns.afraid.org/> you can make a DNS to access the database easily.

12\. Install ngrok (see <https://thisdavej.com/how-to-host-a-raspberry-pi-web-server-on-the-internet-with-ngrok/> for more details)

```bash
sudo npm install --unsafe-perm -g ngrok
```

13\. Start the ngrok server

```bash
ngrok http 80
```

the output should look as follows (note if you close the terminal window the session will be closed

![](https://1203731670-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LriQ0HJOhOOr26B9YAt%2F-LxIriQ086Zfm3W_WoFk%2F-LxJ0SCMcNaVP9yXAot2%2Fimage.png?alt=media\&token=a83fa8af-ebaa-4b0b-9f43-e7469ab218d4)

by navigating to the link provided by your output in a web browser with the directory oe for this example it would be `http://2057a4d3.ngrok.io/oe` should get you to the open enventory login page from any device on any network.
