this webpage is hosted on a drawer-bound fairphone 2 from 2015, running postmarketos
in this tutorial you will be guided through the steps taken to get there
you will end up with a small home server, able to run basic services
we aim to reduce e-waste, encourage reuse and give a second life to forgotten chips
you will need
- an unused android phone
- a charger and power source
- a wifi connection
- a computer running linux (natively or in a virtual machine)
step 1: installing postmarketos
first step is installing postmarketos on your phone
find your device in the devices page and verify that your device is properly supported
…
this webpage is hosted on a drawer-bound fairphone 2 from 2015, running postmarketos
in this tutorial you will be guided through the steps taken to get there
you will end up with a small home server, able to run basic services
we aim to reduce e-waste, encourage reuse and give a second life to forgotten chips
you will need
- an unused android phone
- a charger and power source
- a wifi connection
- a computer running linux (natively or in a virtual machine)
step 1: installing postmarketos
first step is installing postmarketos on your phone
find your device in the devices page and verify that your device is properly supported
keep that page open throughout the installation
install pmbootstrap, the main command-line application for postmarketos
we’ll first generate the image, then flash it to the device
generate the image
update the ports and initialize your device information:
$ pmbootstrap pull
$ pmbootstrap init
when asked for the codename for your device, provide the one listed in your device’s page you opened above
when asked for which user interface to use, you can choose console (which should be the most minimal option) or fbkeyboard to have a minimal keyboard on-screen (which you shouldn’t have to use thanks to ssh, but just in case, it’s fun)
generate the image:
$ pmbootstrap install
flash the image
check your device’s page for how to boot your device in flash mode
usually this means powering the device on with the “volume down” button pressed
connect the phone into your computer and boot it in flash mode
next, check the Installation section of the page and follow any instructions listed there
finally, if you have not already, flash the image to the device:
$ pmbootstrap flasher flash_rootfs
then, reboot the device and verify that postmarketos starts-up correctly
step 2: setting up your server
now that your phone is postmarketos’ed, let’s log into it
the default postmarketos username/password combination is user/147147
keep the phone connected to your computer and ssh into it:
$ ssh user@172.16.42.1
connect the phone to your wifi network:
$ nmcli device wifi connect your_wifi_network --ask
congrats, you now officially have a little local phone server
running this command should show you the phone’s local ip address:
$ ip -4 addr show wlan0 | grep inet | awk '{print $2}' | cut -d'/' -f1
on a typical home router it will have the form 192.168.1.x
you can now plug the phone somewhere safe and connect to it via wifi:
ssh user@192.168.1.x
step 3: serving a web page
create the /var/www/html/ directory:
sudo mkdir -p /var/www/html/
write a simple hello world html file:
$ sudo sh -c 'echo "<h1>hello world</h1>" > /var/www/html/index.html'
add a nftables rule to allow incoming packets on port 80, in /etc/nftables.d/99_http.nft:
inet filter input tcp dport 80 ct state new accept
then restart nftables:
$ sudo systemctl restart nftables
run the following to launch your webserver:
$ httpd -h /var/www/html/
test out the server by curling the website from your computer:
$ curl 192.168.1.x
you should see the <h1>hello world</h1> text from above
now type the ip address in the web browser of any device connected to the same wifi network, and marvel at your own tiny local digital garden
note that this http server will not be automatically restarted if your phone reboots for any reason
extra: remote access
as a preemptive security measure, i would recommend not to open port 22 (used for ssh) to the wider internet
instead you should set up a vpn access to your router box (most support this on their web interfaces) if you need remote access
once you are connected to your local network, access the phone using ssh as before
if you know what you are doing and still want to open up port 22 to the internet, remember to disable password login and set up ssh keys
extra: maintenance
to update the packages on your server, run:
$ sudo apk update
$ sudo apk upgrade
next steps
In the advanced part of this tutorial (still under construction), you will learn how to:
- setup a domain and https
- make the http server persist after reboot
built by louis merlin under the cc by-nc-sa 4.0 license