# Faceboo"C" - 事前準備 contributed by < `dalaoqi` > ## 硬體安裝 參考[官方的安裝流程](https://www.raspberrypi.org/documentation/installation/installing-images/)使用 [Raspberry Pi Imager](https://www.raspberrypi.org/software/) 下載後安裝完畢後執行,選擇安裝的作業系統及安裝的位置 ![](https://i.imgur.com/FPKLuRq.png) 這裡選擇的是 `Ubuntu Server 20.10 (PRi 3/4/400) 64-bit server OS for arm64 architectures` 按下 `Write` 寫入記憶卡 ![](https://i.imgur.com/3imzUTD.png) ![](https://i.imgur.com/SYtArOh.png) 完成後,為了讓系統可以自動連上 wifi ,需要將記憶卡資料夾中的 `network-config` 新增以下資訊: ``` wifis: wlan0: dhcp4: true optional: true access-points: "<wifi network name>": password: "<wifi password>" ``` 將 `<wifi network name>` 及 `<wifi password>` 替換掉為已知的 wifi 名稱及對應的密碼。 同時,在同一個資料夾下,開啟檔名為 `user-data` ``` # On first boot, set the (default) ubuntu user's password to "ubuntu" and # expire user passwords chpasswd: expire: true list: - ubuntu:ubuntu # Enable password authentication with the SSH daemon ssh_pwauth: true ``` 預設的機器名稱及密碼皆為 `ubuntu` 以及 SSH 預設是開啟的狀態。 確認完後,將記憶卡拆下,插入樹莓派中,開機後會自動連上 wifi。 ## 連線設定 為了能夠遠端作業,必須要知道樹莓派目前的 IP ,以利之後用 SSH 進行作業。 打開電腦 `cmd` ,若作業系統為 Windows ,執行 ``` arp -a | findstr dc-a6-32 ``` Linux 或 Mac OS 則執行 ``` arp -na | grep -i "dc:a6:32" ``` 指令會去找出符合字串的 MAC ,並秀出符合 MAC 的相關資訊。指令執行時需要確保電腦與樹莓派在同一個網路底下。 ![](https://i.imgur.com/2sknEr5.png) 前面的 `192.168.11.136` 就是目前樹莓派的虛擬 IP 位址 知道 IP 後,就可以利用 SSH 遠端對樹莓派進行操作,輸入 ``` ssh ubuntu@192.168.11.136 ``` 確認後輸入密碼,系統會要求重新設定一組新的密碼。成功登入如下 ![](https://i.imgur.com/Sn11h4L.png) 目前的 `192.168.11.136` 為虛擬 IP,為了之後方便,需要設定一個實體 IP 給樹莓派。 首先先安裝 `net-tools` ``` sudo apt install net-tools ``` 接著去`/etc/dhcpcd.conf`,新增固定 IP 的資訊 ``` interface wlan0 static ip_address=x.x.x.x/24 static routers=x.x.x.x static domain_name_servers=x.x.x.x ``` 完成後存檔重啟樹莓派,並利用新的 IP 登入 ![](https://i.imgur.com/k2M8wrb.png) 成功遠端登入樹莓派。 ## facebooc 安裝套件及執行 ``` sudo apt-get install build-essential sudo apt-get install libsqlite3-dev make run ``` 打開瀏覽器輸入當初設定的 IP `140.116.82.6:8080` ![](https://i.imgur.com/GviLr21.png) ## 參考文件 https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#4-boot-ubuntu-server https://www.raspberrypi.org/documentation/remote-access/ip-address.md https://roboticsbackend.com/install-ubuntu-on-raspberry-pi-without-monitor/ https://github.com/jserv/facebooc