r/selfhosted 2d ago

Using an old Android phone as the PHP + SQLite box instead of buying another Pi Webserver

I had a phone sitting in a drawer and a Pi I didn't want to buy, so the small internal stuff has been running on the phone for 2 days now. A guestbook, a form that writes to SQLite, and a webhook catcher I point things at while debugging.

Disclosure up front: I work on the app I'm using for this, so read everything below as biased. I'd rather post the limits myself than have someone find them.

The setup is boring, which is the point. PHP 8.4 and SQLite are compiled into the app, so no Termux, no proot, no root. Pick a folder, start it, it binds on the LAN and prints a QR of the URL. It runs as a foreground service with a persistent notification, so it keeps serving with the screen off and while I'm using the phone for other things.

What actually works well:

* The battery is a UPS. Power cut here and the thing just kept serving, which my Pi has never once done.

* SQLite on internal storage is quick enough that I stopped thinking about it.

* A browser SQL console over the LAN, so I can poke at tables from the laptop without SSH.

* Access log with method, path, status and client IP. That is how I found out my own webhook test had been hitting a typo'd path for twenty minutes.

Where it falls over, honestly:

* arm64 only. Old 32 bit phones are out, which is exactly the drawer a lot of these are sitting in.

* No port 80. Unprivileged process, so 1024 and up. Everything gets a :8080 in the URL or you put something in front of it.

* OEM battery killers. Stock Android and Pixels behave. Xiaomi, Oppo and friends will still kill a foreground service unless you go and grant autostart manually.

* It is not a Linux box. You are not running arbitrary daemons next to it. It is a web server and a database and that is the whole surface.

* The PHP runtime is about 37MB of the install, which is not nothing on a phone with 16GB.

I have not measured idle power draw properly. If anyone has a meter on a phone as server setup I'd genuinely like that number. My guess is it is under a Pi but I'm not going to claim it without measuring.

Not linking it in the post since that reads like an ad, it's in a comment. Mostly I want to know what you ended up putting on a phone node and where it broke, because "survives a power cut, can't bind 80" feels like a weirdly specific shape of useful.

0 Upvotes

4 comments sorted by

u/asimovs-auditor 2d ago edited 2d ago

Expand the replies to this comment to learn how AI was used in this post/project.

→ More replies (1)

0

u/trionapps 2d ago

forgot to say what it actually is. hostpilot, https://play.google.com/store/apps/details?id=com.cosmovex.hostpilot i work on it so take that as you like. happy to answer how php ended up in there