DEV Community

sirin k
sirin k

Posted on

Set up LAMP stack in a Pantahub device(RPI3 B+)

Step 1: Burn the RPI3 initial stable image into your sd card.

a) Download RPI3 image

Click to download: https://pantavisor-ci.s3.amazonaws.com/pv-initial-devices/tags/012-rc2/162943661/rpi3_initial_stable.img.xz

b) unxz the device image

Run $ unxz rpi3_initial_stable.img.xz

c) Burn image into sd card using Raspberry Pi Imager 1.2

Step 2: Boot your RPI3

a) Insert your sd card and supply the power

Step 3: Detect & Claim your device

a) Connect a LAN cable between your RPI3 & computer/Router.

b) Open your terminal & run $pvr scan

c) Claim your device

$ pvr claim -c grossly-pleasant-polliwog https://api.pantahub.com:443/devices/5f0316884f8811000a191ab3

d) Log into Panthub.com and check whether the newly claimed device appeared in the dashboard or not.


Step 4: Clone the device to your computer

$ pvr clone https://pvr.pantahub.com/sirinibin/vastly_measured_caribou/0 vastly_measured_caribou

Step 5: Add a new app named "apache-php" & Deploy to the device

a) Move to device root dir

 `$ cd vastly_measured_caribou`

b) Add new app "apache-php" into the device

$ pvr app add apache-php --from=arm32v7/php:7.2-apache

c) Deploy the changes to the device

 $ pvr add .
 $ pvr commit
 $ pvr post

d) Check the device status changes in Pantahub.com dashboard & wait for the status to become "DONE"

Status 1:

Status 2:

Status 3:

Status 4:

e) Verify the "apache-php" installation

Access the device IP: http://10.42.0.231 in your web browser.

Now you can see that the Apache server is started serving on port 80 in your RPI3 device. But it is showing as "Forbidden" because there is nothing to serve.

Step 6: Serve a php script using the newly installed apache2.4 server

a) Add your ssh key to your device user meta data using pantahub.com dashboard

Note: the key name you should use is pvr-sdk.authorized_keys

b) SSH to the newly created app container "apache-php"

 $ ssh -p 8222 php-apache@10.42.0.231

c) Install vim editor

  $ apt-get update
  $ apt-get install vim

d) Place a PHP script index.php inside the apache Document Root folder

  $ cd /var/www/html
  $ vim index.php
  <?php
  phpinfo()
  ?>

e) Access your device IP: http://10.42.0.231/ in your web browser

Step 7: Add "mysql" app to the device & deploy the change

a) Add "mysql" app

$ pvr app add mysql --from=yobasystems/alpine-mariadb:arm32v7 --config-json=<(echo -n -e '{
"Env": [
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "MYSQL_DATABASE=testdb",
  "MYSQL_USER=testuser",
  "MYSQL_PASSWORD=123",
  "MYSQL_ROOT_PASSWORD=123",
  "MYSQL_CHARSET=utf8",
  "MYSQL_COLLATION=utf8_general_ci"
]
}')

b) Deploy the changes

   $ pvr add .
   $ pvr commit
   $ pvr post

Step 8: Add "adminer" app to the device for managing the mysql database

Adminer is a dashboard app which can be used to visually manage the mysql database

By default Adminer will be server through port 8080

a) Add "adminer" app

pvr app add adminer --from=arm32v7/adminer

b) Deploy the changes

   $ pvr add .
   $ pvr commit
   $ pvr post

c) Access the Adminer dashboard by using http://10.42.0.231:8080/

d) Log into the Adminer dasdhboard by entering the below mysql credentials

 Server:10.42.0.231
 Username:root
 Password:123

Now you can easily Create/update/delete mysql databases/tables through Adminer
Now you can deploy your custom LAMP app source code into the dir: /var/www/html of docker image:arm32v7/php:7.2-apache and update docker image tag in src.json then run

pvr app update apache-php --from=arm32v7/php:<NewTag>

Top comments (0)