Running a website from your phone

I’ve got an Android handset that is gathering dust and, despite the fact that the camera is cracked and the screen only works when it feels like it, I wanted to make some use of it. So, after a little bit of fiddling, I’ve turned it into a web server. Not just a web server for displaying a few flat HTML files, but one that’ll run WordPress. The result is running on coolsmartphone.otzo.com – here, for those of you who might be interested, is how I did it.

Running a website from your phone

Firstly, there’s a few problems. Back in the day when I worked for a ISP my broadband came with a fixed external IP address. This would never change, so I could merrily point domain names to that IP and it would just work. Now, however, I’ve got a cheap-save fibre connection from EE and the IP address will change if the router gets rebooted or drops connection. So, if I’m to point a domain to this IP I’ll need something to update that. Here I chose a company called ChangeIP.com. They offer a Dynamic DNS service, and you can choose from a range of subdomains. I chose coolsmartphone.otzo.com because, well… it seemed like a good idea at the time. Next, I needed something to tell the ChangeIP website when my home IP changed. Here I used something called SSH Server. The free version only lets you put one “server” into action – I ideally wanted two. One for an SSH server so that I could connect to my phone remotely and another as a DNS Updater service. In the end I just plumbed for the DNS Updater service, which is easy to setup. You just choose “ChangeIP” from the drop-down, put in the ChangeIP web credentials and then the Android app will feed the current / new IP for your home broadband to them so that your domain goes to the right place. This can be set to start at boot and will do everything without you thinking.

Running a website from your phone

Next problem then, and that’s getting all this working externally. Luckily EE gave me a router with NAT’ing and PAT’ing, which means I basically say..

“Hey, any web traffic coming in from outside should go to this device in my network on this port”

Running a website from your phone

This is where you possibly hit problem three, because most broadband / fibre routers are just setup to dish out DHCP (dynamic) IP addresses internally, so every time you turn on your smartphone you’ll maybe get a different IP. I had to go into the router, alter the DHCP scope and then go into the WiFi settings on the phone to tell it that I wanted to keep a static IP which is outside of the DHCP scope.

Running a website from your phone

Next, and this bit is optional really, but I do like an element of remote access – I setup an SSH server. The earlier app I mentioned just a minute ago would only let you setup one service before you had to start paying, so I downloaded this SSH server app which is fairly simple and just asks for a username and then starts the service on port 2222.

Ahh yes, there’s another “gotcha”. Android won’t let you use the “proper” web and SSH ports unless you start rooting your phone. I’m using a bog-standard handset here and I’ve not rooted it or messed around a great deal. So, back on my FTTC (fibre) router, I tell it that..

“If any traffic comes in externally on port 22, whack it through to the fixed IP of the phone on port 2222 instead”

That worked a treat, and it let me move around the file system and have a look around. I’m a geek after all.

Running a website from your phone

The final, and perhaps most important part, is to actually get yourself a web server app. This is where I did actually spend a bit of cash, but it was only £2.27. Bit Web Server is so simple to get started and comes with a MySQL, Apache and PHP server. Everything in one boat. There’s a PHPMyAdmin too, so you can setup a new database.

This will fire up on another strange port – 8080. Again, I had to tweak the home broadband router to redirect any requests coming in on the “standard” web port (80) to the internal port of 8080 on the fixed IP of the Android smartphone I was using.

Running a website from your phone

Next, to install WordPress I just browsed on the phone and downloaded the ZIP file. After unpacking it on my phone, I put the resulting files into /sdcard/www – where all the web server files are located. Then it’s just a matter of browsing to the site, going through the installation process and – bingo – I’ve got me a WordPress site running from my phone. I have to say, it works a treat. Give it a shot on coolsmartphone.otzo.com because, if you click that link, you’ll be browsing a site which is hosted on a phone which is dangling from a plug in my garage.