While Mapbox hosting is very appealing for its relative ease, you may wish to host your own MBTiles, for example, to minimize cost. TileStream is the open source foundation of Mapbox's hosting service. It runs under Node.js.
While TileStream can technically be installed under Windows with a Node.js install, some dependencies may fail to be installed. It is recommended that you perform the following install in a Linux environment. If you are already running Linux on your organization's server, that's great! You can skip ahead to installing Node.js and TileStream. Fortunately, with Virtual Box and Vagrant, it is possible to set up a Linux virtual machine on your Windows system.
c:\packt\c7\vagrant).
cd c:\packt\c7\vagrant
vagrant init hashicorp/precise32 vagrant up
c:\packt\c7\vagrant). Vagrantfile is the plaintext file that controls the Vagrant configuration. Add the following line to the Vagrantfile to forward the (not yet created) Node.js port to your Windows localhost:config.vm.network "forwarded_port", guest: 8888, host: 8088
vagrant reload
vagrant ssh variable should start it up and connect it to the instance in this directoryHost: 127.0.0.1
Port: 2222
Username: vagrant
Password (if needed): vagrant
Private key: c:/packt/c7/vagrant/.vagrant/machines/default/virtualbox/private_key
Use the following commands to install Node.js from the chris-lea package archive. This is the Node.js source recommended by Mapbox. The preceding Vagrant setup steps ensure that the dependencies, such as apt, are set up as needed. Otherwise, you may install some other dependencies. Also, note that on systems that do not support GNU/Debian, this will not work; you will need to search for the relevant repositories on yum, find RPMs, or build it from the source. However, I'm not sure that any of this will work.
Note that all the following commands are to be run in the Linux instance. If you followed the preceding steps, you will run these through an SSH client such as Putty:
sudo apt-add-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs
Install Git and clone the TileStream source to a new directory. Run the following command line:
git clone https://github.com/mapbox/tilestream.git cd tilestream npm install
You must add your MBTiles file under /home/vagrant/Documents/MapBox/tiles. You can use your preferred file transfer client to do this; I like WinSCP. Just use the same SSH connection info you used for SSH.
Finally, start TileStream:
./index.js
Now, you can preview your TileStream service at http://localhost:8088.
Click on the info button to obtain the address to the PNG tiles. You can modify this by removing the reference to the x, y, and z tiles and adding a .json extension to get TileJSON such as http://localhost:8088/v2/c7_8b4e46.json.
Now, simply modify the OpenLayers example to refer to this .json address instead of Mapbox, and you will have a fully nonMapbox use for MBTiles.
The code demonstrating this is at http://localhost:8000/utfgrid-ts.html.