How to host (run Linux distro) on non-rooted Android phone
You probably have older phone in your drawer, or there is plenty of phones with cracked screens on craigslist or ebay with good CPU for close to nothing. Here is simple way to turn Android phone to Linux device without rooting.
Go to PlayStore and install "UserLAnd" app.
Select your distro to install. You can choose full desktop environment (vnc) or just the server version (ssh). It takes some time to install.
For those that like to dig in source code: https://github.com/CypherpunkArmory/UserLAnd
Phone IP can be found under System -> About Phone. UserLAnd SSH uses the port 2022 by default. Once you get to the SSH session, you can do:
apt install nano apache2 php mariadb-server
then change ports in /etc/apache2/ports.conf, because the Linux runs on top of your Android in its userspace and has no access to privileged ports. Then restart apache
service apache2 restart
All these problems are related to reboot.
on my setup, apache2 failed to start automatically, needed to be restarted manually
phone does not start automatically when charger is connected. This can be changed by resetting the "off-mode-charge" flag to zero with fastboot tool.
Unfortunately my old Pixel1 was locked and did not allow me to change the flag. However, as long as the outage does not last longer than battery or phone does not crash, should not be big deal.
- Not sure how to start UserLAnd session automatically after reboot. The app seems to be somewhat running after reboot, but the session is not started.
After succesfull phpinfo(), host an actual non-trivial website
Setup wireguard tunnel to external VPS with static IP, that exposes the container to the world
Take a benchmark test and compare with actual real hosting VPS.