本文主要是介绍在树莓派3B上手动安装RaspAP,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、简介
最近一直在折腾树莓派3B,周末到图书馆去看了看和树莓派相关的书籍,感觉都很陈旧,没找到想要的书。今天就来记录一下RaspAP的手动安装方法。
二、我目前在使用的云服务器推荐,学Linux不搞个云服务器始终感觉不爽
要稳定性、安全性、不差钱的可以使用阿里、腾讯等大厂的云服务器。
本人穷屌丝一枚,所以我用的是免费的“三丰云”,同时提供"免费虚拟主机"和“免费云服务器”产品,有兴趣的可以试一下。
“三丰云”我已经用了一段时间,感觉还是很不错的,速度快也很稳定。
三丰云 https://www.sanfengyun.com 链接。
大家可以点击前往查看是否需要。
三、RASPAP支持的发行版
RaspAP was originally made for Raspberry Pi OS, but now also installs on the following Debian-based distros.
Distribution | Release | Architecture | Support |
---|---|---|---|
Raspberry Pi OS | (64-bit) Lite Bookworm | ARM | Official |
Raspberry Pi OS | (32-bit) Lite Bookworm | ARM | Official |
Raspberry Pi OS | (64-bit) Lite Bullseye | ARM | Official |
Raspberry Pi OS | (32-bit) Lite Bullseye | ARM | Official |
Armbian | 23.11 (Jammy) | ARM | Beta |
Debian | Bookworm | ARM / x86_64 | Beta |
Ubuntu | Server 23.04 (Lunar) | ARM / x86_64 | Beta |
四、手动安装RaspAP的步骤
# 要确保 Raspberry Pi 上的 WiFi 无线电未被阻止,请执行以下命令
sudo rfkill unblock wlan
# 安装软件包
sudo apt-get install lighttpd git hostapd dnsmasq iptables-persistent vnstat qrencode php8.2-cgi jq isoquery
# 启用 PHP
sudo lighttpd-enable-mod fastcgi-php
sudo service lighttpd force-reload
sudo systemctl restart lighttpd.service
# 创建 Web 应用程序
sudo rm -rf /var/www/html
sudo git clone https://github.com/RaspAP/raspap-webgui /var/www/html# 编辑配置文件
WEBROOT="/var/www/html"
CONFSRC="$WEBROOT/config/50-raspap-router.conf"
LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"")HTROOT=${WEBROOT/$LTROOT}
HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//')
awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf
sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/# 将其链接到 Web 服务并重新启动
sudo ln -s /etc/lighttpd/conf-available/50-raspap-router.conf /etc/lighttpd/conf-enabled/50-raspap-router.conf
sudo systemctl restart lighttpd.service# 将 sudoers 规则复制到目标位置
cd /var/www/html
sudo cp installers/raspap.sudoers /etc/sudoers.d/090_raspap# 创建目录
sudo mkdir /etc/raspap/
sudo mkdir /etc/raspap/backups
sudo mkdir /etc/raspap/networking
sudo mkdir /etc/raspap/hostapd
sudo mkdir /etc/raspap/lighttpd
sudo mkdir /etc/raspap/system# 设置权限
sudo chown -R www-data:www-data /var/www/html
sudo chown -R www-data:www-data /etc/raspap# 将控制脚本移动到目标目录
sudo mv installers/enablelog.sh /etc/raspap/hostapd
sudo mv installers/disablelog.sh /etc/raspap/hostapd
sudo mv installers/servicestart.sh /etc/raspap/hostapd
sudo mv installers/debuglog.sh /etc/raspap/system# 设置日志记录和服务控制脚本的所有者和权限
sudo chown -c root:root /etc/raspap/hostapd/*.sh
sudo chmod 750 /etc/raspap/hostapd/*.shsudo chown -c root:root /etc/raspap/system/*.sh
sudo chmod 750 /etc/raspap/system/*.sh# 复制并设置控制脚本的所有者
sudo cp installers/configport.sh /etc/raspap/lighttpd
sudo chown -c root:root /etc/raspap/lighttpd/*.sh# 将服务文件移动到正确的位置并启用它
sudo mv installers/raspapd.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable raspapd.service# 复制配置文件
sudo mv /etc/default/hostapd ~/default_hostapd.old
sudo cp /etc/hostapd/hostapd.conf ~/hostapd.conf.old
sudo cp config/hostapd.conf /etc/hostapd/hostapd.conf
sudo cp config/090_raspap.conf /etc/dnsmasq.d/090_raspap.conf
sudo cp config/090_wlan0.conf /etc/dnsmasq.d/090_wlan0.conf
sudo cp config/dhcpcd.conf /etc/dhcpcd.conf
sudo cp config/config.php /var/www/html/includes/
sudo cp config/defaults.json /etc/raspap/networking/# 禁用并复制 bridge 配置
sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd
sudo cp config/raspap-bridge-br0.netdev /etc/systemd/network/raspap-bridge-br0.netdev
sudo cp config/raspap-br0-member-eth0.network /etc/systemd/network/raspap-br0-member-eth0.network# 优化 PHP
sudo sed -i -E 's/^session\.cookie_httponly\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.cookie_httponly = 1/' /etc/php/8.2/cgi/php.ini
sudo sed -i -E 's/^;?opcache\.enable\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/opcache.enable = 1/' /etc/php/8.2/cgi/php.ini
sudo phpenmod opcache# 路由和 IP 转发
echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/90_raspap.conf > /dev/null
sudo sysctl -p /etc/sysctl.d/90_raspap.conf
sudo /etc/init.d/procps restartsudo iptables -t nat -A POSTROUTING -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE
sudo iptables-save | sudo tee /etc/iptables/rules.v4# 启用 hostapd
sudo systemctl unmask hostapd.service
sudo systemctl enable hostapd.service
这篇关于在树莓派3B上手动安装RaspAP的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!