<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Blog of Max Horvath</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.maxhorvath.com/atom.xml" />
    <id>tag:www.maxhorvath.com,2008-03-19://1</id>
    <updated>2008-10-31T17:52:50Z</updated>
    <subtitle>For more quality in software products ...</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Open Source 4.1</generator>

<entry>
    <title>Gotcha&apos;s when running Movable Type on FastCGI</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/08/gotchas-when-running-movable-type-on-fastcgi.html" />
    <id>tag:www.maxhorvath.com,2008://1.18</id>

    <published>2008-08-29T14:46:01Z</published>
    <updated>2008-10-31T17:52:50Z</updated>

    <summary>Movable Type is a large application with a lot of files. In a CGI context that application is loaded into memory every single time, and there is no ability to leverage a cache across a session or multiple requests. When using FastCGI, the application is loaded into memory so that it doesn&apos;t have to be reparsed and interpreted every single request. This dramatically increases performance. Unfortuantly some scripts of Movable Type are not compatible with FastCGI. A few of those scripts are i.e. mt-check.cgi or mt-xmlrpc.cgi (which is needed for XmlRPC transactions with your blog).</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Apache" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="Apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="fastcgi" label="FastCGI" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
<a href="http://www.movabletype.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/movabletype.org');">Movable Type</a> is a large application with a lot of files. In a CGI context that application is loaded into memory every single time, and there is no ability to leverage a cache across a session or multiple requests.
</p>

<p>
When using <a href="http://www.fastcgi.com/" onClick="javascript: pageTracker._trackPageview ('/outgoing/fastcgi.com');">FastCGI</a>, the application is loaded into memory so that it doesn't have to be reparsed and interpreted every single request. This dramatically increases performance.
</p>

<p>
Unfortuantly some scripts of Movable Type are not compatible with FastCGI. A few of those scripts are i.e. mt-check.cgi or mt-xmlrpc.cgi (which is needed for XmlRPC transactions with your blog).
</p>

<h3><strong><big>How to get the FastCGI-incompatible files up and running</big></strong></h3>

<p>
In the end the solution is quite easy. You just need to tell Apache to not run some of Movable Type's scripts through FastCGI, but through classic CGI.
</p>

<p>
In your Apache configuration you need to activate add the following lines to the directives handling the Movable Type direcory:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
<FilesMatch "^mt-(check|config|testbg|upgrade|xmlrpc)\.cgi$">
    SetHandler cgi-script
</FilesMatch>
</textarea>

<p>
That's all you need to do - Movable Type will run flawlessly.
</p>

<h3><strong><big>What if you don't have direct access to your Apache configuration?</big></strong></h3>

<p>
To ease up things you can also just create a template for a .htaccess file. It may also be much easier to use and maintainable this way. Just make sure you don't rebuild it each time you rebuild your site.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Making phpUnderControl (CruiseControl) accessible via a Proxy</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/08/making-phpundercontrol-cruisecontrol-accessible-via-a-proxy.html" />
    <id>tag:www.maxhorvath.com,2008://1.10</id>

    <published>2008-08-15T10:51:30Z</published>
    <updated>2008-10-31T17:58:30Z</updated>

    <summary>phpUnderControl is a customization of CruiseControl. For those wanting to run CruiseControl behind an Apache webserver without configuring mod_jk or the like, this short how-to is just right.</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Apache" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="PHPUnit" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="Apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="cruisecontrol" label="CruiseControl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="phpundercontrol" label="phpUnderControl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
<a href="http://www.phpundercontrol.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/phpundercontrol.org');">phpUnderControl</a> is a customization of <a href="http://cruisecontrol.sourceforge.net/" onClick="javascript: pageTracker._trackPageview ('/outgoing/cruisecontrol.sourceforge.net');">CruiseControl</a>.
</p>

<p>
For those wanting to run CruiseControl behind an <a href="http://httpd.apache.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/apache.org');">Apache</a> webserver without configuring <code>mod_jk</code> or the like, this short how-to is just right.
</p>

<h3><strong><big>Installing phpUnderControl / CruiseControl</big></strong></h3>

<p>
This article is not about installing phpUnderControl or CruiseControl. For refernces see <a href="http://www.phpundercontrol.org/documentation.html#id25" onClick="javascript: pageTracker._trackPageview ('/outgoing/phpundercontrol.org');">http://www.phpundercontrol.org/</a> or <a href="http://cruisecontrol.sourceforge.net/gettingstartedbindist.html#Quick_Start" onClick="javascript: pageTracker._trackPageview ('/outgoing/cruisecontrol.sourceforge.net');">http://cruisecontrol.sourceforge.net/</a>.
</p>

<h3><strong><big>Configuring Apache as a proxy</big></strong></h3>

<p>
So we are considering you have your phpUnderControl / CruiseControl instance up and running at http://localhost:8080/. We are also considering you have an instance of the Apache webserver up and running.
</p>

<p>
First we'll need to enable the <code>proxy</code> module of Apache. Consult the apache manual on how to enable the module in your instance of the Apache webserver. Now edit your Apache vHost or httpd.conf configuration.
</p>

<textarea name="code" class="css:nogutter:nocontrols" cols="60" rows="10">
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

ProxyRequests Off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</textarea>

<p>
You need to make sure that <code>mod_proxy.so</code> and <code>mod_proxy_http.so</code> do point  to the right location on your harddisk.
</p>

<h3><strong><big>Fixing URLs</big></strong></h3>

<p>
Proxying already works with this configuration, but unfortunately clicking any link in your installation of phpUnderControl / CruiseControl would point to the direct installation of the instance. This is where mod_jk would come into play. But as we're just wanting a quick and easy resolution for runnning phpUnderControl / CruiseControl behind the Apache webserver, we'll be solving this issue quite easily:  
</p>

<p>
Make sure to enable the <code>ext_filter</code> module. Now edit your Apache vHost or httpd.conf configuration again:
</p>

<textarea name="code" class="css:nogutter:nocontrols" cols="60" rows="10">
LoadModule ext_filter_module /usr/lib/apache2/modules/mod_ext_filter.so

ExtFilterDefine fixurls mode=output intype=text/html
cmd="/bin/sed s/localhost:8080/phpuc/g"

SetOutputFilter fixurls
</textarea>

<h3><strong><big>Conclusion</big></strong></h3>

<p>
Just restart your Apache webserver and your instance of phpUnderControl / CruiseControl should be running perfectly well behind your Apache webserver.
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Smart URLs for your Movable Type blog</title>
    <link rel="alternate" type="text/html" href="http://www.maxhorvath.com/2008/03/smart-urls-for-your-movable-type-blog.html" />
    <id>tag:www.maxhorvath.com,2008://1.8</id>

    <published>2008-03-19T14:47:32Z</published>
    <updated>2008-10-31T18:07:00Z</updated>

    <summary>Moveable Type is great when it comes to being lightweight on your webserver, because it creates most of your blog&apos;s functions as static content. It also creates a really nice URL structure, which comes in very nice when you are an URL fetishist like me. But you certainly have been bugged by the fact that MovableType&apos;s installation URL kicks in when you need to use MovableType&apos;s search function. Today I&apos;d like to show you, how to configure your Moveable Type installation and your Apache Webserver to display smart URLs everywhere (expect the administration interface).</summary>
    <author>
        <name>Max Horvath</name>
        <uri>http://www.maxhorvath.com</uri>
    </author>
    
        <category term="Apache" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Movable Type" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apache" label="Apache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="mod_rewrite" label="mod_rewrite" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.maxhorvath.com/">
        <![CDATA[<p>
Moveable Type is great when it comes to being lightweight on your webserver, because it creates most of your blog's functions as static content. It also creates a really nice URL structure, which comes in very nice when you are an URL fetishist like me. But you certainly have been bugged by the fact that MovableType's installation URL kicks in when you need to use MovableType's search function. Today I'd like to show you, how to configure your Moveable Type installation and your <a href="http://httpd.apache.org/" onClick="javascript: pageTracker._trackPageview ('/outgoing/apache.org');">Apache Webserver</a> to display smart URLs everywhere (expect the administration interface).
</p>

<p>
My blog makes use of what follows. Although I don't offer Movable Type's internal search function, but Google webpage search, my blog does have a tags page, with all tags being linked to related posts. This feature typically uses MovableType's search engine.
</p>

<h3><strong><big>Editing your templates</big></strong></h3>

<p>
First you should edit three related widget templates: <em>Search</em>, <em>Syndication</em> and <em>Tag Cloud</em>. You will find those templates by visiting the web administration interface of your Moveable Type installation. Click <em>Design</em> &gt; <em>Templates</em>, then in the right sidebar on <em>Widgets</em>.
</p>

<p>
Using the <em>Tag Cloud</em> template, I will show you exemplary, how to edit all three templates:
</p>

<textarea name="code" class="html:nogutter:nocontrols" cols="60" rows="10">
<div class="widget-tag-cloud widget">
    <h3 class="widget-header">Tag Cloud</h3>
    <div class="widget-content">
        <ul class="widget-list">
            <mt:Tags limit="20" sort_by="rank">
                <li class="rank-<$mt:TagRank max="10"$>
                           widget-list-item">
                    <a href="<$MTBlogURL$>tag/<$MTTagName$>">
                        <$mt:TagName$>
                    </a>
                </li>
            </mt:Tags>
        </ul>
    </div>
</div>
</textarea>

<p>
The important part to look for is <code>&lt;a href="&lt;$MTBlogURL$&gt;tag/&lt;$MTTagName$&gt;"&gt;&lt;$mt:TagName$&gt;&lt;/a&gt;</code>. What I'm doing is to point the tags to an URL like: <code>http://www.example.com/tag/SampleTag</code>.
</p>

<h3><strong><big>Telling Apache to understand the changes</big></strong></h3>

<p>
Now we need our webserver to understand, what those new links mean. In your Apache configuration you need to activate <a href="http://httpd.apache.org/docs/2.2/rewrite/" onClick="javascript: pageTracker._trackPageview ('/outgoing/apache.org');">mod_rewrite</a>. Next we need to provide a rewrite rule, so the Apache knows where to redirect a call to the URL to.
</p>

<p>
In our particular case it would look like this:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
RewriteEngine on
RewriteRule ^tag/(.*)$ /cgi-bin/mt-search.cgi?tag=$1&blog_id=$$$&IncludeBlogs=$$$
</textarea>

<p>
Remember to replace both <code><strong>$$$</strong></code> with your current IDs (just click a tag and see, which IDs are being used).
</p>

<h3><strong><big>Where to repeat those changes</big></strong></h3>

<p>
To also apply those changes to <em>Search </em>and <em>Syndication</em>, you need to modify the templates <em>Search</em> and <em>Syndication</em> accordingly.
</p>

<p>
In Apache you should add those two lines:
</p>

<textarea name="code" class="php:nogutter:nocontrols" cols="60" rows="10">
RewriteRule ^/search/(.*)$ /cgi-bin/mt-search.cgi?q=$1&blog_id=$$$&IncludeBlogs=$$$
RewriteRule ^/feed/(.*)$ /cgi-bin/mt-search.cgi?tag=$1&Template=feed&blog_id=$$$&IncludeBlogs=$$$
</textarea>

<p>
Again, remember to replace both <code><strong>$$$</strong></code> with your current IDs (should be the same ones you have had to use for the tags rewrite rule).
</p>

<h3><strong><big>What if you don't have direct access to your Apache configuration?</big></strong></h3>

<p>
To ease up things you can also just create a template for a .htaccess file. It may also be much easier to use and maintainable this way. Just make sure you don't rebuild it each time you rebuild your site.
</p>]]>
        
    </content>
</entry>

</feed> 