Image missing.
how to repurpose your old phone into a web server

created: Nov. 22, 2025, 6:16 p.m. | updated: Nov. 25, 2025, 8:36 p.m.

back to homehow to repurpose your old phone into a web serverthis webpage is hosted on a drawer-bound fairphone 2 from 2015, running postmarketosin this tutorial you will be guided through the steps taken to get thereyou will end up with a small home server, able to run basic serviceswe aim to reduce e-waste, encourage reuse and give a second life to forgotten chipsyou will needan unused android phonea charger and power sourcea wifi connectiona computer running linux (natively or in a virtual machine)step 1: installing postmarketosfirst step is installing postmarketos on your phonefind your device in the devices page and verify that your device is properly supportedkeep that page open throughout the installationinstall pmbootstrap, the main command-line application for postmarketoswe'll first generate the image, then flash it to the devicegenerate the imageupdate the ports and initialize your device information:$ pmbootstrap pull $ pmbootstrap initwhen asked for the codename for your device, provide the one listed in your device's page you opened abovewhen 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 installflash the imagecheck your device's page for how to boot your device in flash modeusually this means powering the device on with the "volume down" button pressedconnect the phone into your computer and boot it in flash modenext, check the Installation section of the page and follow any instructions listed therefinally, if you have not already, flash the image to the device:$ pmbootstrap flasher flash_rootfsthen, reboot the device and verify that postmarketos starts-up correctlystep 2: setting up your servernow that your phone is postmarketos'ed, let's log into itthe default postmarketos username/password combination is user / 147147keep the phone connected to your computer and ssh into it:$ ssh [email protected] the phone to your wifi network:$ nmcli device wifi connect your_wifi_network --askcongrats, you now officially have a little local phone serverrunning this command should show you the phone's local ip address:$ ip -4 addr show wlan0 | grep inet | awk '{print $2}' | cut -d'/' -f1on a typical home router it will have the form 192.168.1.xyou can now plug the phone somewhere safe and connect to it via wifi:ssh [email protected] 3: serving a web pagecreate 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 acceptthen restart nftables:$ sudo systemctl restart nftablesrun 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.xyou should see the <h1>hello world</h1> text from abovenow 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 gardennote that this http server will not be automatically restarted if your phone reboots for any reasonextra: remote accessas a preemptive security measure, i would recommend not to open port 22 (used for ssh) to the wider internetinstead you should set up a vpn access to your router box (most support this on their web interfaces) if you need remote accessonce you are connected to your local network, access the phone using ssh as beforeif 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 keysextra: maintenanceto update the packages on your server, run:$ sudo apk update $ sudo apk upgradenext stepsIn the advanced part of this tutorial (still under construction), you will learn how to:setup a domain and httpsmake the http server persist after rebootbuilt by louis merlin under the cc by-nc-sa 4.0 license

2 weeks, 4 days ago: Hacker News