Hello World

Installation procedure for Raspberry Pi with MQTT and OpenHAB2

Using image: 2018-10-09-raspbian-stretch.img

Prepare and update

sudo apt-get update
sudo apt-get dist-upgrade -y

Install mc

sudo apt-get install mc -y

Install nodejs

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

check nodejs

node -v
npm -v

Install mosquitto

sudo apt-get install mosquitto -y

install mosquitto password

sudo mosquitto_passwd -c /etc/mosquitto/passwd 
sudo nano /etc/mosquitto/mosquitto.conf
append to this file:
password_file /etc/mosquitto/passwd
allow_anonymous false
save and exit

Install nginx

sudo apt-get install nginx
sudo /etc/init.d/nginx start

Install PHP

sudo apt-get install php-fpm

enable PHP in nginx

cd /etc/nginx
sudo nano sites-enabled/default
Add "index.php to the line index"

reload

sudo /etc/init.d/nginx reload

Install openhab

wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list | sudo apt-get update
sudo apt-get install openhab2 openhab2-addons --fix-missing

prepare for autostart

sudo systemctl enable openhab2
sudo reboot

Install samba

sudo apt-get install samba samba-common-bin

Edit config

sudo nano /etc/samba/smb.conf
Append the following:
[share]
Comment = Pi shared folder
Path = /share
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes

Set samba password

sudo smbpasswd -a pi
sudo smbpasswd -a root

Restart samba

sudo /etc/init.d/samba restart