Setting Up a Raspberry Pi

Simple collections of steps to set up a Raspberry Pi. I used a Raspberry Pi Zero W that will be used a weather dashboard.

Setting up basics and node

Update repos

sudo apt-get update

Install dependencies

sudo apt-get install -y gcc g++ make python git

Install node and npm

sudo curl -Lf# "https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-linux-armv6l.tar.gz" | sudo tar xzf - -C /usr/local --strip-components=1 --no-same-owner

Test node is working

node -v
sudo apt-get update
sudo apt-get upgrade

Setting Up Apache and PHP

More information: https://pimylifeup.com/raspberry-pi-apache/

To install apache2 on your Raspberry Pi and some modules

sudo apt install apache2 -y
sudo a2enmod proxy_http

Firstly, we add the user pi (our user) to the www-data group, the default group for Apache2.

Secondly, we give ownership to all the files and folders in the /var/www/html directory to the www-data group.

sudo usermod -a -G www-data pi
sudo chown -R -f www-data:www-data /var/www/html

Install PHP

sudo apt install php7.3 php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y

php -v

Setting Up pm2

sudo npm install -g pm2

Example of starting a script:

pm2 start /home/pi/apps/weather-api/app.js --name=api --watch
pm2 startup
pm2 save