User:Pedro Sá Couto/Prototyping 5th/Flask App/Raspberry Pi into NGINX server: Difference between revisions
No edit summary |
No edit summary |
||
Line 127: | Line 127: | ||
$ sudo deluser pi | $ sudo deluser pi | ||
</pre> | </pre> | ||
=RASPI CONFIG= | |||
===01 Install NGINX=== | |||
<pre style="color: silver; background: black;"> | |||
$ sudo apt install nginx | |||
</pre> | |||
===02 Switch to root=== | |||
<pre style="color: silver; background: black;"> | |||
$ su | |||
</pre> | |||
===03 Create a non-default mini static website=== | |||
<pre style="color: silver; background: black;"> | |||
# mkdir /var/www/<name> | |||
# echo "OHAI" > /var/www/<name>/index.html | |||
</pre> | |||
===04 Disable nginx default site=== | |||
<pre style="color: silver; background: black;"> | |||
# rm /etc/nginx/sites-enabled/default | |||
</pre> | |||
===05 Switch to root=== | |||
===06 Switch to root=== |
Revision as of 22:52, 29 March 2020
RASPI CONFIG
01 Format SDcard to FAT32
02 Flash SDcard with Linux ISO
- Raspbian Buster Light, https://www.raspberrypi.org/downloads/raspbian/
- you can use dd or a mounter like etcher https://www.balena.io/etcher/
03 Default login
- Login: pi
- Password: raspberry
04 SSH config
$ cd /boot $ sudo touch ssh $ sudo reboot
05 Change hostname
$ sudo raspi-config
- Item no. 2 on the menu: Network Options
06 Add new user
$ sudo adduser <username>
07 Add new user to sudo
$ sudo adduser <username> sudo
08 Change su/root password
$ sudo passwd root
09 Setting locale
$ su $ echo "LC_ALL=en_US.UTF-8" >> /etc/environment $ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen $ echo "LANG=en_US.UTF-8" > /etc/locale.conf $ locale-gen en_US.UTF-8
10 Setting locale
$ cd ~ $ mkdir .ssh $ cd .ssh $ touch authorized_keys $ touch config $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/authorized_keys $ cd ~/.ssh $ ssh-keygen $ cat id_rsa.pub >> authorized_keys $ sudo apt-get install putty-tools $ puttygen id_rsa -o id_rsa.ppk
11 Get the public key onto RPI
- Copy the contents of id_rsa.pub from you machine
$ cat <path to id_rsa.pub>
- Paste and save them into authorized_keys file on RPi
$ cd ~/.ssh $ sudo nano authorized_keys
12 Set static IP address
- Check gateway
$ sudo route -n
- Open etc config
$ sudo vim /etc/dhcpcd.conf
- Paste these lines in the top
#Static IP text block interface eth0 static ip_address=192.168.1.75 static routers=192.168.1.1 static domain_name_servers=8.8.8.8 8.8.4.4
13 Setup fast ssh on your machine
$ cd ~/.ssh $ nano config
Host nginxhost User <username> Hostname 192.168.1.75 Port 22 Identityfile /path/to/.ssh/id_rsa Serveraliveinterval 30
14 Disable pwd and root login
- Uncomment PasswordAuthentication and set it to no
- Uncomment PermitRootLogin prohibit-password
$ sudo nano /etc/ssh/sshd_config
- Reload SSH
$ sudo /etc/init.d/ssh restart
- Reboot RPi
$ sudo reboot
15 Remove pi user
$ sudo pkill -u pi $ sudo deluser pi
RASPI CONFIG
01 Install NGINX
$ sudo apt install nginx
02 Switch to root
$ su
03 Create a non-default mini static website
# mkdir /var/www/<name> # echo "OHAI" > /var/www/<name>/index.html
04 Disable nginx default site
# rm /etc/nginx/sites-enabled/default