If you are developing sites on your own machine, you probably have run into a situation where you wanted to share what you’re working on with another person. Or, you want to test your locally hosted site on another device, say a mobile phone.
Most web developers will develop locally because it’s a lot faster and convenient. But there is one major pain point: you’re stuck looking at the site from just that machine. That is, unless you somehow expose the locally hosted site through the network. And there are quite a few ways to do this, with each having it’s own pros and cons. I felt it worthwhile to post my research into the various different ways to accomplish this.
Accesssing local sites via IP addresses
The most direct way to share your local site with your LAN is to simply work with IP Addresses. In many cases locally hosted sites have urls such as ‘http://local.mydevelopmentsite.com’. The local part refers to a site hosted on the machine itself, so this address will only work on the machine the site is running on. Alternatively though, you can reference your local site through an ip address – such as http://192.168.1.9/mydevelopmentsite/ – and make the necessary configurations so that you can type in that IP address and browse the site from another computer on the network.
This solution is simple enough and it works. It’s a great solution if you want to just test a site over your LAN. The downside is you have to use ugly ip addresses. Setting up multiple sites is a pain, as you have to screw around with multiple ip addresses or work with subfolders. It doesn’t work out of the box outside your LAN, so if you want to share a site with a client or friend, you need something else. Also, if the IP address changes, it’s an even greater pain (You would have to make sure your router and devices get a fixed ip address instead of appointing these dynamically). Keep in mind that if you’re working on a WordPress site, you’ll have to make the changes in the settings table of your database every time the domain name changes.
DesktopServer
This is a software product primarily aimed at WordPress developers. It makes setting up local WordPress sites ridiculously easy, taking out the pain of going through much of the configuration manually. It also has a neat feature which automates the process of making your sites accessible over your Lan (not over the internet). I believe it works with the ip address of your local machine, much like is mentioned above (except this software automates most of the setup). I haven’t tested this software myself yet, so I can’t really vouch for it yet. But if it does indeed use ip addresses, the same caveats apply as listed above. Also, I’m not sure if you can set up multiple sites or just one.
Turning a pc into a server
You can use your computer as a server and make your local site available to the rest of the internet. The Lamp/Wamp/Xamp/Mamp stacks are all capable of making your sites public.The benefit here is that you can share your site outside of your network, but you still have to deal with ugly ip addresses, which may change due to your internet service provider. It also makes your computer a bigger target to hacking attacks.
Of course, lots of programmers have their own dedicated servers running at home for private use. You could easily convert an unused pc as a dedicated server. These things are a little more complex and you generally really need to know what you’re doing to keep things secure. And let’s be honest, maintaining a server is not on top of everybody’s wish list.
Dynamic DNS
DNS is a system that does true magic: it converts human friendly domain names into the actual numeric addresses that computer networks understand. The web relies on DNS to convert domains names into addresses. Some routers may let you setup Dynamic DNS just for your own local network, allowing you to appoint domain names for the addresses on your network. This is great because these only work within your network and people outside your network won’t be able to access the domain names successfully.
You can also use a service such is provided by DYN. They let you setup domain names for your local sites, or any device you want to make accessible for that matter. That way, you (and anyone else) can access those sites from anywhere, even from other locations. The heavy lifting DYN does is making sure your domain names resolve to your sites ip address from anywhere in the world. Because the IP may change quite frequently, you have to update it with the DNS to keep it working. That’s a tricky thing, but easily solved with DYN. A software client is downloaded to your device that will monitor for any IP changes and correct the settings with the DNS setup automatically. As you might have guessed, this isn’t a free service, but it isn’t expensive either at $29.95/year.
Localtunnel
Localtunnel is a free service sponsored by Twilio which lets you share localhost over the web. It’s a pretty straightforward affair: you install LocalTunnel on your homeserver and set up subdomain under localtunnel.com (for example: mytestsite.localtunnel.com). Your local site can then become accessible through that subdomain. It’s really simple and it’s free. So what’s the caveat? There are three potential drawbacks. First, you’re stuck with localtunnel as the root domain. Second, you need to be able to install Localtunnel on your home server and your stack might not be able to run it amicably alongside your apache/php/mysql setup. And third, you have to rely on Localtunnel and the people administering it, which might not make it suitable for every use case. While there is no reason to mistrust the good folks, there are no guarantees of uptime and security for a free service like that.
Note: There are other services that operate just like Localtunnel, many of these are paid services. They all work pretty much the same. You can even run Localtunnel yourself as it’s open source.
Tonido plug
Tonido plug is a plug computer, which is effectively a little server that you can hook up to a hard drive. It’s a really tiny device that draws little power. Tonido is geared toward providing your own private cloud, making your files accessible to your other devices as well as perhaps your friends, family or colleagues. The device comes with a server stack that is compatible with say, WordPress sites, with a bit of configuration. What this means is that you can have a very low cost server running 24/7 for your local sites. Really, I see this as the holy grail if it weren’t for the configuration that is needed. Right now installing something like WordPress alongside Tonido’s own cloud software looks non-trivial and there are no guides available. If only they would make creating local sites as easy as a click of a button. That would be sweet indeed.
Other Plug Computers
Tonido is not the only plug computer in the game, in fact there are quite a number of them, many which are cheaper to boot. But these other plugs require more setup steps to get everything running and you have to figure this all out on your own as they don’t come pre-loaded with all the right things installed and configured.
Pagekite
Pagekite is a service run by an Icelandic company. They are somewhat similar to Localtunnel, except the setup is even easier and you don’t have to worry about compatibility issues with your server stack. The process involves installing python (if your system doesn’t have it already) and running their python script. You need an account with their site to set up your ‘kites’, aka your local sites. You can set up any number of these using subdomains off of the pagekite.net root domain. They support SSL connections which is good for security and privacy, but as Pagekite is the middleman, you have to implicitly trust them (no reason not to though as they are a privacy/security conscious group). Pricing is good also, you can get a free trial and pay a pretty low fee anywhere from $4/month and upwards after the trial finishes.
Syncing
If all your site’s local assets are static, syncing your site’s files is actually pretty easy to do. You could even use something like dropbox to keep folders in sync and let other devices run the site from that folder. If you are using a local database, it’s technically possible, but not really advisable if the site is very active as you could easily create conflicts while storing data in the database.
Portable
There are portable versions of many AMP stacks available that let you install your server on a thumbdrive, which you can then load up on any computer you please. Sharing your sites can then be as easy as sharing your thumb drive. It’s very handy for developers on the go. This solution doesn’t scale well obviously and it doesn’t get around the use case of testing sites on mobiles, but for some situations it’s the easiest and simplest solution.
Please build this product
While there are plenty of methods to sharing local sites online, it could be a lot easier. I would love to see a plug computer which is optimized for the task of making local sites accessible across your local network or over the internet. It can be done with today’s plug computers, but it’s a solution that involves a lot of configuration steps. And a setup that is so easy that regular consumers could use would open up the door to new kinds of applications that could compete with today’s ubiquitous cloud based services.
Update 30/10/2013: A new way to share your WordPress site
A few months ago I came across the ArkOS initiative. It’s a linux based operating system targeted toward plug devices such as the Raspberry Pi. One of the coolest things about it is that it comes with a WordPress installer straight from their interface, which makes setting up WordPress sites on a plug computer super easy. I’ll be giving this a go in few months.