Setting up a local testing MovableType server

Often it's useful to set up a test server. I do this before I upgrade to a new version of MovableType, for example, to make sure the new version works properly. I set up a Linux Virtual Machine in my home office that's similar to my production servers and run the test there. There's one problem.

It does not work.

Well, the server works. Unfortunately when I linked between blog pages I embedded the full absolute URL (including "http://blog.rickk.com") so I keep getting linked back to the production server. But it's not just self-inflicted; MovableType embeds the absolute URL all over the place, too.

There are some tricks that mostly work including host file and DNS hacks, but I prefer this solution: setting up a proxy server.

On most Linux distributions it's a piece of cake to install a proxy server. What I did is install the squid proxy server, configure it to rewrite URLs and then not actually cache anything, just pass the request to the real server. What this does is map every request to blog.rickk.com to the test server, blogtest2.rickk.com.

Why a proxy server? It's supported by all of the browsers, but more importantly it's a per-browser configuration setting. This means that I can keep my regular browser (Chrome) pointed to production and set the proxy server on Firefox to point to test. This ends up being very handy.

Setting up Squid

The way to install Squid varies between Linux distribution but for Ubuntu it was as simple as:

sudo apt-get install squid

Edit the /etc/squid/squid.conf file adding:

http_access allow localnet
url_rewrite_program /etc/squid/redirector
cache deny all

The http_access allows any machine on my local network to use the proxy server.
The url_rewrite_program specifies the program to rewrite the blog URLs.
The cache specifies that nothing will be cached, which makes testing a little easier.

Even though we're not caching data, we still need to initialize the cache:

squid -z

And create the redirector script in /etc/squid/redirector. Be sure to make it executable (chmod 755 redirector) and edit it for the URLs for your blog and test servers.


Start squid (this may vary depending on your Linux distribution):

start squid

Browser Settings

In Firefox, the setting is in Advanced - Network - Connection - Settings.

Set the HTTP Proxy to the server running the proxy server and set the port to 3128.

It's a little hard to tell whether this is 100% working because the URLs in the address bar of your browser will still read the production URL. If you're using something like Firebug it will show that IP address the data is coming from is your proxy server.

But you really need to examine the server logs on your test server to make sure that the request is being set to your test server instead of the production server.

About this Entry

This page contains a single entry by Rick Kasguma published on March 5, 2012 7:35 AM.

Code Box was the previous entry in this blog.

Optimizing MovableType Google Indexing is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Pages