Creating a copy of your website using GNU Wget for Windows or OS X

There are times when you want to have a copy of your site (the frontend / user side). GNU Wget has been around a long time, but in my opinion, it’s still a great tool to backup / mirror websites.

Wget has many options and parameters, of which I won’t even scratch the surface, but below are the simple steps to get Wget setup and running on Windows and OSX machines. Wget is a command line utility, so it might appear overwhelming, but don’t worry, it’s cake!

Windows steps:

Step 1. Download / install Wget. Visit¬†http://gnuwin32.sourceforge.net/packages/wget.htm and choose to download the Setup labeled “Complete package, except sources.”

Step 2. After installation is finished, open a command prompt (cmd.exe).

Step 3. Go to your GNU application folder (on 64 bit it’s in¬†C:\Program Files (x86)\GnuWin32\bin, on 32 bit, it’s probably in¬†C:\Program Files\GnuWin32\bin).

Step 4. To test if wget is installed correctly, run “wget -V“. It should return the current version and some credit. If not, revisit previous steps.

Step 5. To download / mirror a site, run ¬†wget -e robots=off -r -l 0 -P “c:\\temp” http://www.chrisbitting.com – replacing “c:\temp” with the folder you want the site files to download to and “chrisbitting.com” with your site address.

wget_pc

 

You should now see the command prompt update with the progress – depending on the size of your site – it may take some time to download everything. After it’s finished, your directory should contact a mirror of your site, including html, css, images, etc.

 

Apple OS X steps:

Step 1. Open a blank terminal.

Step 2. Install homebrew by running:

ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”

Step 3. After installing brew (and entering your password), run:

brew doctor

Step 4. Now install Wget using:

brew install wget

Step 5. When installation finishes, run “wget -V” to ensure Wget installed correctly.¬†It should return the current version and some credit. If not, revisit previous steps.

Step 6.¬†To download / mirror a site, run ¬†wget -e robots=off -r -l 0 -P “/temp” http://www.chrisbitting.com – replacing “/temp” with the folder you want the site files to download to and “chrisbitting.com” with your site address.

wget_osx

You should now see the terminal¬†update with the progress – depending on the size of your site – it may take some time to download everything. After it’s finished, your folder¬†should contact a mirror of your site, including html, css, images, etc.

To see the multitude of options Wget provides, run “wget –help“. Happy downloading!

 

Creating a copy of your website using GNU Wget for Windows or OS X

Local web server for testing / development using Node.js and http-server

localhost8080If you’re developing html / javascript applications and want to test locally, many times you will go beyond what local file access (file:///C:/…) in browsers will allow (like XMLHttpRequests, json calls, cross domain access and Access-Control-Allow-Origin restrictions).

A simple solution instead of deploying your code to apache or IIS is to install a local http server. http-server for Node.js is a fast, easy install and app that will allow you to use any directory as a http://localhost.

Installing this simple http server only takes a few steps:

  1. Install node.js if you don’t already have installed (from¬†http://nodejs.org)
  2. In a command prompt / terminal, now run:
    npm install http-server -g
    

    (this installs http-server globally so you can access from any folder or directory)

  3. Now using command prompt or terminal, browser to a folder with some html you want to serve as http. (ie: c:\someproject\).
  4. Run:
    http-server
    
  5. Open your browser and visit http://localhost:8080.

 

You can change port 8080 (the default) to anything using “-p”, so¬†http-server -p¬†8088 would change your local site to¬†http://localhost:8088

Run¬†http-server –help¬†to see the other options available for running.

Local web server for testing / development using Node.js and http-server

Accessing Visual Studio 2010’s built in web server remotely

So as you’re developing / debugging a Visual Studio 2010 web app, you may want to access the local web server from a remote machine. Visual Studio will be accessible locally using an address like: http://localhost:5524, but if you try from another machine on your network using the ip address ie: http://192.168.4.2:5524, you won’t be able to reach the solution.

The easiest way to get this working:
1. Download SPI Port Forward.
2. Install SPI Port Forward.
3. The config is a little backwards in my opinion, so after running SPI Port Forward, enter the remote port you want to use in the ¬†“Local Port” text box (ie: 8080), and in the “Remote Host” enter “localhost” (usually) and in the “Remote Port” enter your local Visual Studio debugging port (in my example, 5524.
4. Click Activate

SPI Port Forward Setup

You should now be able to access your Visual Studio web app (provided it’s open and running) using http://(your machine ip)/(the port you choose above) ie: http://192.168.4.2:8080

Happy Testing!

Note: If you have any additional local or network firewalls, they may interfere with the setup and you’ll have additional steps…
Accessing Visual Studio 2010’s built in web server remotely