Raspberry Pi 3 Model B+ 配置RaspAP
环境
- Raspbian Stretch
- Apache 2.4
- PHP 7.0
官方的一键安装脚本
1 |
wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap |
脚本用的是 lighttpd,这里因为环境是apache,所以需要手动配置
手动配置
安装组件
1 |
sudo apt-get install git php7.0-cgi hostapd dnsmasq vnstat |
增加www-data权限
1 |
nano /etc/sudoers |
底部增加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
www-data ALL=(ALL) NOPASSWD:/sbin/ifdown www-data ALL=(ALL) NOPASSWD:/sbin/ifup www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan_results www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] reconfigure www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd start www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd stop www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq start www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq stop www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now www-data ALL=(ALL) NOPASSWD:/sbin/reboot www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] down www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] up www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan[0-9] www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/servicestart.sh |
增加web目录并下载raspap
1 2 |
sudo mkdir /var/www/raspap sudo git clone https://github.com/billz/raspap-webgui /var/www/raspap |
配置权限
1 |
sudo chown -R www-data:www-data /var/www/raspap |
1 2 3 |
sudo mkdir /etc/raspap sudo mv /var/www/raspap/raspap.php /etc/raspap/ sudo chown -R www-data:www-data /etc/raspap |
配置执行文件
1 2 |
sudo mkdir /etc/raspap/hostapd sudo mv /var/www/html/installers/*log.sh /etc/raspap/hostapd |
配置开启启动
1 |
nano /etc/rc.local |
exit 0前增加
1 2 3 |
echo 1 > /proc/sys/net/ipv4/ip_forward #RASPAP iptables -t nat -A POSTROUTING -j MASQUERADE #RASPAP iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE #RASPAP |
重启服务
1 2 |
sudo systemctl restart rc-local.service sudo systemctl daemon-reload |
重启hostapd
1 2 |
sudo systemctl unmask hostapd.service sudo systemctl enable hostapd.service |
重启主机
1 |
sudo reboot |
配置apache
1 |
nano /etc/apache2/sites-available/raspap.conf |
写入
1 2 3 4 5 6 7 |
<VirtualHost *:80> DocumentRoot /var/www/raspap ServerSignature Off <Directory /var/www/raspap > Options -Indexes </Directory> </VirtualHost> |
重启apache
1 |
service apache2 restart |
There are no comments yet