Whether you have a $50 mini PC that you leave plugged in all the time or a 5-inch smartphone that you carry with you, you can use any Android device as a full fledged web server that’s accessible either on LAN or from anywhere on the Internet. With an Android web server, developers can easily test their code without paying for a hosting service. Freelancers can carry a copy of the web tools they’ve built with them to show their clients. Home and small office users can even set up custom web tools for users on the local network.
Here’s how to set up a web server on your Android phone, tablet or mini PC.
1. Install and launch KSWEB on your Android device. The app only has a six-day free trial, after which it costs $2.99. There are a number of other web server apps, including Bit Web ($2.39) and Servers Ultimate, but we chose KSWEB for this tutorial because it is one of the simpler options.
2. Navigate to the IP address listed by KSWEB in your computer’s browser or to localhost:8080 on the device itself.
3. Click the link for KSWeb Interface and enter the default username and password (admin and admin).
4. Select System settings and change the default password from “admin” to something else.
5. Select KSWEB settings, enter a MySQL shell password and hit save. You can stick with the default, blank password but it is unadvisable to have a blank password, even if your server isn’t connected to the Internet.
6. Select a root directory for your site by tapping Document Root in the KSWEB app’s settings menu and entering the appropriate file path. You may wish to keep the default directory (/mnt/sdcard/htdocs), but we recommend that you save space by putting the folder on a microSD card, if your Android device has one.
You can now visit your site by navigating to localhost:8080 on the Android device or by navigating to the IP address displayed by KSWeb. However, at this point, you will only see KSWEB’s default home page and you will only be able to access it from within the local network.
MORE: Galaxy S4 Tips
If you want users outside of your local network to see your web server, you must make a few tweaks to your router settings. Every brand of router has its own administration menus so the names of menus and fields will vary slightly, but these are the general steps you must take to make your Android web server available on the Internet. Our screen shots and menus were taken from a TRENDnet TEW-633GR router.
1. Log into your router’s administration page from your PC. If you don’t know its IP address, check the user’s manual for your router.
2. Make a static IP address available for your Android device. Local IP addresses tend to start with 192.168.10.1 and go up from there. If your router provides DHCP (dynamically assigned I IPs) to an address range, anything lower than that range will be available for a static assignment. For example, our router uses addresses 192.168.10.101 to 192.168.10.200 for dynamic assignments so we chose to give our phone the 192.168.10.99 address. Some routers will also let you reserve a specific address.
3. Configure your router to forward port 80 to port 8080 on the static IP address you’re assigning to your Android device. On our router, this function was labeled “Add virtual server” but on others it will called “port forwarding.”
4. Navigate to the Wi-Fi menu on your Android device.
5. Long press the name of your Wi-Fi network and select Modify Network.
6. Check show advanced options.
7. Select Static under IP settings and enter the static IP address you chose (or reserved) and tap Save.
8. Search Google for the term “What’s My IP” to find your router’s public IP address. Google will display it above the search results.
Anyone on the Internet will now be able to navigate to your site, as long as you give them this IP address to use. Unfortunately, unless you pay for a plan with a static IP address, your number could change the next time your router reboots. You can solve this problem by purchasing a domain and using a dynamic DNS service such as dyn.com that always directs that domain to your current IP address, no matter how often it changes.
Keep in mind that hosting a web site from your home Internet connection may violate your ISP’s terms of service so, if you’re planning to have everyone on the Internet visiting, you may want to upgrade your account or purchase a web hosting package.
When your Android device goes to sleep, the server software goes to sleep also so users will not be able to connect to it. There are a number of apps that will keep your device from sleeping, but we like Keep Screen On because it allows you to decide which apps will keep the screen awake and to set the device not to sleep while charging.
To keep your Android device awake while the server is on:
1. Install Keep Screen On.
2. Toggle the service to On and tap settings.
3. Toggle Keep screen on while charging to on. If you plan to keep your server up and running, you should leave your device plugged in anyway.
4. Tap Applications. A list of all applications appears.
5. Check the box next to KSWEB and tap the light bulb icon in the upper right corner of the screen.
6. Select “When app is running” from the pop-up menu that appears.
With KWSWEB running, you browse your site directly from the Android device by navigating to localhost:8080 or you can visit its IP address from any computer on your local network. However, there’s no point in visiting a site that has no content. If you want to put HTML files, PHP scripts, images or other files on your server, you can either create them locally or send them from your PC via FTP.
To edit Android Web server files locally:
1. Install DroidEdit or another code editor on your Android device.
3. Save files to the web server’s directory by selecting Save as and navigating to the appropriate folder.
To send files to your server over FTP:
1. Install FTP Server by Olive Tree.
2. Tap Home directory in FTP Server’s settings menu and select Custom folder.
3. Tap Custom folder in the settings menu and enter the KSWEB’s root directory (/mnt/sdcard/htdocs if you didn’t change it).
4. Set a username and password by tapping on those options in settings.
5. Tap the start button in FTP server. If the server is active the button will turn green after you tap it. You can tap it again to turn FTP off.
6. Forward port 21 to port 2221 on your Android device’s IP address in your router software if you want to FTP from outside of your local network.
Users will now be able to upload and download files from your web server by entering either the local or public IP addresses into an FTP client such as Filezilla.
With PHP and MySQL on your server, you can install any of a number of content management systems (CMSes), including WordPress, a very powerful publishing tool used by over 8.5 million sites including several large ones. To install WordPress on your Android server:
1. Install Astro File Manager if you don’t already have it.
2. Download the WordPress zip file from wordpress.org.
3. Launch Astro File Manager and navigate to the Download folder (usually under /sdcard/Download) on your device.
4. Long press the wordpress zip file and select Extract Here.
5. Copy the wordpress folder under Download and then paste it into the server’s root directory.
6. Navigate to the device’s local IP address at port 10,000 on your PC. PhpMyAdmin will load.
7. Enter the root as the username and the password that you assigned to it when configured KSWEB.
8. Click the Databases tab at the top of the screen.
9. Enter “wordpress” in the Create database field and tap Create.
10. Navigate to your server’s IP address with the port :8080 and path /wp-admin/install.php (ex: 192.168.10.99:8080/wp-admin/install.php) on your PC.
11. Click Create a Configuration File when prompted
12. Enter your database user name and password when prompted by WordPress.
13. Click Run the Install when asked by WordPress to do so.
14. Enter your site title, desired username, password and email address then hit the Install WordPress button. These are the credentials you will use to log into WordPress after it installs.
WordPress will then confirm your install and allow you to log in for the first time.
You will be able to log into WordPress and write new posts by going to your IP address /wordpress/wp-admin.