Want to run a simple web server off of an iPad or iPhone? If you have iSH linux shell running in iOS then you can easily start and run a simple web server directly from an iPhone or iPad. By running iSH and starting a web server with python 3 you can then serve either HTML files or a directory listing to the same device via localhost, or to anyone on the same network with the iOS devices IP address. This is obviously not going to be as fully functional or featured as running apache or nginx, but if you want to geek around with a simple local html development environment or serve something via http from an iPhone or iPad, it’ll do the trick. Plus, it’s just plain cool.
How to Run a Web Server on iOS with iSH and python
- Install iSH on the iPhone or iPad as directed here if you haven’t done so already, otherwise launch iSH
- At the iSH command line in iOS, enter the following syntax and hit return:
- When you see the ‘Serving HTTP on 0.0.0.0 port 8000’ message, now you’re ready to connect the web server from either the same device or another:
python3 -m http.server
- To connect to the iOS web server from the same device (localhost), point any web browser to:
Replacing ‘DEVICE-IP-ADDRESS’ with the IP address of the device running iSH and the python web server, you can find the iOS devices IP address in Network Settings if needed. (Example screenshot shows the iOS device IP of 192.168.1.10)
Pretty cool, right?
You’ll probably want to put some basic index.html file at the present working directory where you’re running the python server from. If you don’t have a simple index.html file in the current working directory on the iOS device where the python command is being run, then a simple directory listing is shown instead.
While the simple web server is running, you’ll see standard logging information appear in the iSH terminal window, showing access times, dates, IP addresses, GET and PUSH requests, 404 errors, and other typical access log information.
Anyway, while the isn’t a particularly practical solution to web hosting or web development and you likely won’t be using this for anything too serious, it’s still fun and interesting as a proof of concept for us geekier folks. Perhaps one day we’ll get some easy web server setup in the iOS world like MAMP for Mac, but until then the solutions are fairly limited and most web workers and developers will continue to be using ssh to connect to a web server for the time being.
If you know of any other interesting or geeky solutions for setting up a web server or web sharing natively with an iOS device, share with us in the comments!