Last active
February 1, 2025 06:00
-
-
Save RichardTMiles/5f57c29151c5d3e3d49c0024966df156 to your computer and use it in GitHub Desktop.
Alpine Linux Raspberry Pi Webserver Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eEx | |
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/main" | tee -a /etc/apk/repositories > /dev/null | |
echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" | tee -a /etc/apk/repositories > /dev/null | |
apk update | |
apk add apache2 | |
rc-update add apache2 default | |
service apache2 start | |
service apache2 status | |
# Check if it’s listening on port 80 | |
netstat -tulnp | grep httpd | |
# Allow Firewall Access | |
apk add iptables | |
iptables -A INPUT -p tcp --dport 80 -j ACCEPT | |
rc-service iptables save | |
# Test the Web Server | |
echo "<h1>Apache is running on Alpine!</h1>" > /var/www/localhost/htdocs/index.html | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eEx | |
apk add openssh | |
rc-update add sshd default | |
service sshd start | |
service sshd status | |
# allow root ssh login with password | |
tee -a /etc/ssh/sshd_config > /dev/null <<EOL | |
PermitRootLogin yes | |
EOL | |
# firewall | |
iptables -A INPUT -p tcp --dport 22 -j ACCEPT | |
rc-service iptables save | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eEx | |
apk update | |
apk add wpa_supplicant iw dhcpcd | |
ip link | |
ip link set wlan0 up | |
iw dev wlan0 scan | grep SSID | |
wpa_passphrase "YourSSID" "YourPassword" > /etc/wpa_supplicant/wpa_supplicant.conf | |
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf | |
dhcpcd wlan0 | |
# test connection with google DNS server | |
ping -c 5 8.8.8.8 | |
# get the devices ipv6 on local network | |
ip -6 a show wlan0 | |
# get the devices ipv4 on local network | |
ip -4 a show wlan0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment