- BalenaEtcher
- SSH
- WiFi
- Boot the RPI
- Login over WiFi
- Install NGINX + PHP
- NPM
- Composer
- ZSH
- Oh-My-Zsh
- Moving to different WiFi network
- Get device info
- Static private IP address
- Change hostname
- More info
- TODO
Download full raspbian from https://www.raspberrypi.org/downloads/raspbian/.
- On OSX >= Catalina open BalenaEtcher with
sudo /Applications/balenaEtcher.app/Contents/MacOS/balenaEtcher- Select the Raspbian image and the SD card and click
Flash - Remove and palce back the SD card for the next steps
Enable ssh with the following command:
touch /Volumes/boot/ssh- Create a file in the root of boot
nano /Volumes/boot/wpa_supplicant.confand add the following content
country=NL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Makkinga"
psk="password"
key_mgmt=WPA-PSK
id_str="home"
}
network={
ssid="Rosegaar.nl WiFi"
psk="0622516682"
key_mgmt=WPA-PSK
id_str="rosegaar"
}Remove the SD card, plug it into the RPI and turn it on
- Clear out previous references
ssh-keygen -R raspberrypi.local- Login over SSH
- Password is
raspberry
- Update RPI
sudo apt-get update
sudo apt-get upgrade- Remove Apache
sudo apt-get remove apache2- Install NGINX
sudo apt-get install nginx- Start NGINX
sudo systemctl start nginx- Get the RPI's local IP
hostname -I- Test the server by visiting
http://IPADDRESSin a browser
- Install PHP
sudo apt-get install php7.3-fpm php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-curl php7.3-zip php7.3-xml -y- Edit the default NGINX configuration file
2.1 Open the file
sudo nano /etc/nginx/sites-enabled/default2.2 Add index.php to index
index index.html index.htm;index index.php index.html index.htm;2.3 Find and replace
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#}location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}sudo systemctl reload nginxsudo chown -R pi:www-data /var/www
sudo chmod u+rxw,g+rx-w,o-rwx /var/www
sudo chmod g+s /var/wwwsudo nano /var/www/html/index.php<?php phpinfo(); ?>- Detect What Version of Node.js You Need
The processor on Raspberry Pi is ARM, but depends on the model there can be ARMv6, ARMv7 or ARMv8. This 3 versions of ARM is supported by Node.js. So first of all type this in your terminal on raspberry pi to detect the version that you need:
uname -m- Download the tar.gz
wget https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-armv6l.tar.gz- Extract the Archive
tar -xzf node-v8.9.0-linux-armv6l.tar.gz- Copy Node to /usr/local
cd node-v8.9.0-linux-armv6l/
sudo cp -R * /usr/local/- Check If Everything Is Installed Ok
node -v
npm -v- Download and install Ccomposer
curl -sS https://getcomposer.org/installer | php- Move to /usr/local/
sudo mv composer.phar /usr/local/bin/composer- Check If Everything Is Installed Ok
composersudo apt install zshsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"If you put a file named wpa_supplicant.conf in the small FAT32 boot partition of a Raspbian SD card the system will use the information in that file to connect to your wireless network. The wpa_supplicant.conf file should contain the following:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=NL
network={
ssid="WiFi SSID"
psk="WPA/WPA2 passphrase"
key_mgmt=WPA-PSK
}
The wpa_supplicant.conf file normally resides at /etc/wpa_supplicant/wpa_supplicant.conf. When Raspbian finds one in the boot partition it will move it to its correct location and use it to connect to the network. This makes it easy to reconfigure WiFi, since the boot partition is accessible from any computer (Windows, Mac, Linux, Chrome OS).
cat /proc/device-tree/modelreturns something like
Raspberry Pi 4 Model B Rev 1.2
Raspbian Jessie, or Jessie Lite – the current Raspbian operating systems at the moment – have a DHCP client daemon (DHCPCD) that can communicate with the DHCP servers from routers. The configuration file of a DHCP client daemon allows you to change the private IP address of a computer and set it up in the long term. The following instructions will assign a static IPv4 address with 32 bits (not to be confused with an IPv6 address, which has 128 bits available) to the Raspberry Pi.
Before you begin with the assignment of a private IP address for Raspberry Pi, check whether DHCPCD is already activated using the following command:
sudo service dhcpcd statusIn case it’s not, activate DHCPCD as follows:
sudo service dhcpcd start
sudo systemctl enable dhcpcdNow make sure that the configuration of the file /etc/network/interfaceshas the original status. For this, the iface configuration needs to be set at manual for the interfaces.
For the editing of the activated DHCPCDs, start by opening the configuration file /etc/dhcpcd.confand running the following command:
sudo nano /etc/dhcpcd.confYou’ll now carry out the configuration of the static IP address. If your Raspberry Pi is connected to the internet via an Ethernet or network cable, then enter the command
interface eth0if it takes place over Wi-Fi, then use this command
interface wlanTo assign an IP address to Raspberry Pi, use the command
static ip_address=
followed by the desired IPv4 address and the suffix /24 (an abbreviation of the subnet mak 255.255.255.0). For example, if you want to link a computer with the IPv4 address 192.168.0.4, then you need to use the command
static ip_address=192.168.0.4/24
It goes without saying that the address used here is not yet used anywhere else. As such, it also can’t be located in the address pool of a DHCP server.
You still then need to specify the address of your gateway and domain name server (usually both are the router). Raspberry Pi turns to the gateway address if an IP address to which it wants to send something is outside of the subnet mask (in the example, this would mean outside of the range 192.168.0). In the following command, the IPv4 address 192.168.0.1 is used as an example as both the gateway and DNS server. The complete command looks like this in our example (where a network cable is used for the internet connection):
interface eth0
static ip_address=192.168.0.4/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
The command lines above match the IPv4 addresses that you want to use for your Raspberry Pi, or where your router is assigned. Save the changes with ‘Ctrl + O’ and then press the enter key. Close the configuration file with ‘Ctrl + X’. Restart to adopt the newly assigned static IP address in the network:
sudo rebootNow use a ping command to check whether the Raspberry Pi is accessible in the network with its new IP address:
ping raspberrypi.localIf the connection of the IP address was successful, you’ll see that you can reach it under the new IP address with a ping.
- Change
/etc/hostname
sudo nano /etc/hostnameChange raspberrypi to your desired hostname.
Hit CTRL+O and then ENTER to Save.
Hit CTRL+X to Exit.
- Change
/etc/hosts
sudo nano /etc/hostsChange raspberrypi to your desired hostname.
Hit CTRL+O and then ENTER to Save.
Hit CTRL+X to Exit.
- Reboot
sudo reboothttps://desertbot.io/blog/headless-raspberry-pi-3-bplus-ssh-wifi-setup