8623d74e |
Raspbian 'stretch' - system build notes
1. Copy os disk image to SD card.
2. Mount the SD card to the host computer and navigate
to the boot volume of the SD card.
3. If using wired Ethernet, skip to step 6.
4. Edit the wpa_supplicant.conf file with your wifi ssid and
wifi password.
5. Copy the wpa_supplicant.conf file to the root of the boot
volume.
6. Create an empty file named "ssh" in the root of the boot
volume.
7. Unmount the SD card and install in the Pi Zero. Apply
power and boot up the Pi Zero.
8. Secure shell into the Pi Zero by running
ssh pi@raspberrypi.local
The password is 'raspberry'
9. Configure the following by running
sudo raspi-config
In System Options modify the following
hostname: nodepower
password: YOUR_PASSWORD
In Interface Options modify the following
I2C: ON
In Localisation Options modify the following
Locale: en_US.UTF-8 UTF-8
Timezone: PACIFIC
Keyboard: US
WLAN: US
10. If using wired Ethernet, disable wifi by adding the following
line to the end of the /boot/config.txt file
dtoverlay=disable-wifi
This helps to conserve power.
11. Disable Bluetooth by adding the following line to the end of
the '/boot/config.txt' file:
dtoverlay=disable-bt
This helps to conserve power.
[Optional] Run the once off command:
sudo systemctl disable hciuart
12. Set up ssh keys on client and import the public key
to the Pi Zero .ssh directory. Create .ssh directory
on the Pi Zero. In .ssh create a file authorized_keys
and copy the public key to it.
13. Backup and then modify /etc/ssh/sshd_config as follows
#PermitRootLogin prohibit-password
PermitRootLogin no
#X11Forwarding yes
X11Forwarding no
Optionally turn off password authentication
#PasswordAuthentication yes
PasswordAuthentication no
14. Setup tmpfs by backup and then modifying /etc/fstab. Add
the following lines to the bottom of the file.
# uncomment if needed for web apps
# These changes store all non-essential logs in ram to reduce
# stress on the SD card due to frequent writes.
tmpfs /tmp tmpfs nodev,nosuid,size=20M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=20m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=20m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=20m 0 0
15. Reboot the Pi Zero by running
sudo reboot
16. Run updates by running the commands
sudo apt-get update
Optionally run all software updates
sudo apt-get upgrade
sudo reboot
17. Install vim
apt-get install vim
18. Optionally copy pi backup archive from the ssh client to
the /home/pi folder
scp pi.zip pi@nodepower.local:~
19. Restore files and directories from backup archive by running
unzip pi.zip
Use 'mv' to move folders and files to their appropriate locations.
20. Make backups of /etc/rc.local, /etc/motd. Then, acting as superuser
copy to /etc from the unzipped directory the files rc.local and motd.
21. Install rrdtool
sudo apt-get install rrdtool
22. Install web server
Apache2
======
sudo apt-get install apache2 -y
sudo a2enmod rewrite
sudo service apache2 restart
PHP
===
sudo apt-get install php libapache2-mod-php -y
sudo service apache2 restart
23. Acting as superuser, backup and then modify
/etc/apache2/mods-available/userdir.conf
# changed {date} by {name} to allow user .htacess file
#AllowOverride FileInfo AuthConfig Limit Indexes
AllowOverride All
24. Enable user directories in apache2
sudo a2enmod userdir
25. Acting as superuser, backup and then modify
/etc/apache2/sites-available/000-default.conf
# changed 12-06-2019 by JLO to make user pi the html document root
#DocumentRoot /var/www/html
DocumentRoot /home/pi/public_html
26. Acting as superuser, backup and then modify
/etc/apache2/mods-available/php7.3.conf to allow user directories
by commenting the lines at bottom of file. E.g.,
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>
27. Enable php in apache2
sudo a2enmod php7.3
28. Acting as superuser, backup and then modify /etc/apache2/envvars
to create apache2 logs in tmpfs. Add the following lines at the top
of the file
if [ ! -d /var/log/apache2 ]; then
mkdir /var/log/apache2
fi
29. Acting as superuser, enable apache2 to access files the tmpfs /tmp
directory by backing up and then modifying
/lib/systemd/system/apache2.service
# changed {date} by {name} to allow apache to follow symlinks
# to the /tmp folder in tmpfs
#PrivateTmp=true
PrivateTmp=false
30. Reload system deamons
sudo systemctl daemon-reload
31. Restart apache2 service
sudo systemctl restart apache2
32. Install i2c smbus python library by running
sudo apt-get install python-smbus
33. Reboot the Pi Zero by running 'sudo reboot'.
34. Test all above modifications.
|