Raspberry Pi 4 Install CentOS 7 With gcc and PostgreSQL、ecpg
樹莓派 4 安裝 CentOS 7 -
★ 下載 CentOS 7 及解壓、燒錄到SD。
https://www.centos.org/centos-linux/
點入後,是可下載的伺服器列表:
選一個離自己近一點的 Server,就選 ftp.yz.yamagata-u.ac.jp 這樣下載速度是不是會快一點?
下載 CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-4-2009-sda.raw.xz 這個檔案,
解壓後會得到 CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-4-2009-sda.raw,將它燒錄到SD卡上,
SD插入Raspberry Pi 4就可開機。
★ 初次開機、設定 wifi、有線網路、更新系統、建立使用者、SSH 設定
開機後,使用者用 root,密碼為 centos,進行登入。
登入後,可以:
[root@localhost~]cat README
README 裡面說可以用 rootfs-expand 指令來 Resize SD 卡。
Resize SD 後,先將root密碼改掉:
[root@localhost~]passwd
接著設定 wifi:
[root@localhost~]nmtui
出現:
設定完成,用 ifconfig 查看,wlan0 已經可運作了。
設定有線網路固定IP Address:
1. 建立檔案:
/etc/sysconfig/network-scripts/ifcfg-eth0 內容:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
PREFIX=24
IPADDR=xxx.xxx.xxx.xxx
2. 存檔後,重啟網路服務:
[root@localhost~]sudo systemctl restart network
進行系統更新:
[root@localhost~]yum update -y
建立一個使用者,並具有 sudo 權限:
指令 - useradd UserName -G wheel -p Password
[root@localhost~]useradd thei -G wheel -p thei123
修改 SSH 禁止 root 登入
[root@localhost~]sudo vim /etc/ssh/sshd_config
搜尋 PermitRootLogin 關鍵字,並改為:
PermitRootLogin no
存檔後,重啟 SSH 服務:
[root@localhost~]sudo systemctl restart sshd.service
設定開機時,自動啟動SSH:
[root@localhost~]sudo systemctl enable sshd.service
設定時區:
查看系統支援的時區:
[root@localhost~]sudo timedatectl list-timezones
更改時區:
[root@localhost~]sudo timedatectl set-timezone Asia/Taipei
★ 安裝相關軟體:gcc、postgreSQL等
1. 安裝gcc:
[root@localhost~]sudo yum group install -y "Development Tools"
2. 安裝postgreSQL:
[root@localhost~]sudo yum install -y postgresql-server postgresql-contrib postgresql-devel
Setup Database:
[root@localhost~]sudo postgresql-setup initdb
啟動 PostgreSQL:
[root@localhost~]sudo systemctl start postgresql
設定開機啟動 PostgreSQL:
[root@localhost~]sudo systemctl enable postgresql
修改 postgres 的密碼:
[root@localhost~]sudo passwd postgres
防火牆增加 5432 Port:
[root@localhost~]sudo firewall-cmd --zone=public --permanent --add-port=5432/tcp
開完防火牆,系統要重開機才會生效。
postgresql.conf 路徑:/var/lib/pgsql/data