Skip to content

Instantly share code, notes, and snippets.

@RichardTMiles
Last active February 1, 2025 06:00
Show Gist options
  • Save RichardTMiles/5f57c29151c5d3e3d49c0024966df156 to your computer and use it in GitHub Desktop.
Save RichardTMiles/5f57c29151c5d3e3d49c0024966df156 to your computer and use it in GitHub Desktop.
Alpine Linux Raspberry Pi Webserver Setup
#!/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
#!/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 is a two session process
# on alpine linux
apk add tmux
# SSH into the box and run
tmux new-session -s mysession
# (optional) List active sessions
tmux list-sessions
# then watch the session with
tmux attach-session -t mysession
#!/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