Sean Kerr built and currently maintains a simple web application engine (’tain’t a framework!) called Redline. He and a few other guys I know (Wess & Brandon) have raved about the deadly speed+simplicity of it for quite awhile now, so I thought I’d give it a go with a site I’m building for my day job.

To begin, I set up a basic vhost container in Apache in which to drop the RL code:

1
2
3
4
5
6
7
8
9
<VirtualHost *:80>
    ServerName redline.local
    DocumentRoot /sites/redline.local/www
 
    <Directory /sites/redline.local/www>
        Options -Indexes, FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>

Then I create the site directory, download the Redline package from Sean’s site, and unzip it:

1
2
3
4
5
6
 drew@server$  mkdir -p /sites/redline.local
 drew@server$  cd /sites/redline.local
 drew@server$  wget http://code-box.org/work/redline-0.1.zip
 drew@server$  unzip redline-0.1.zip
 drew@server$  cp -R redline-0.1/* .
 drew@server$  rm -rf redline-0.1/

At this point, the contents of my /sites/redline.local/ directory is:

1
2
3
4
5
6
7
 cache/
 config.xml
 docs/
 lib/
 modules/
 tags/
 www/

Redline expects all requests to be rewritten through the document root’s www/index.php script in order to properly dispatch each request. To get that running right, I create the following .htaccess file under www/:

1
2
3
4
5
6
7
RewriteEngine On
 
# don't rewrite the index script, or any CSS, javascript, or image files
RewriteRule ^(index\.php|js|css|images) - [NC,L]
 
# everything else goes through the index bootstrap
RewriteRule (.*) index.php/$1 [L]

Another problem I ran into is that the dispatcher parses $_SERVER['PATH_INFO'] in order to determine what’s being requested, but for some reason on my VirtualBox server (Ubuntu 8.10, Apache2) I don’t have that variable available. I googled a bit to find out how to get it set, but the most sensible solution (AcceptPathInfo On) didn’t pan out either. Instead, I cracked open Redline’s config.xml and told it to use REQUEST_URI instead of PATH_INFO:

1
2
3
4
...
    <!-- request path details -->
    <define name="RL_PATH_INFO">REQUEST_URI</define>
..

Redline is built to parse that XML config and generate a PHP script that gets stored under the cache/ directory, which means that directory will need to be writable for the user that Apache runs as (www-data, nobody, apache, etc). There are a few ways to handle this, but the quick and dirty option is to just chmod 777 cache, which effectively gives every user on the server read/write access to everything in that directory. Since I own the whole machine it’s not a security concern, but in a shared environment you’d want to take a slightly less shotgun approach (assuming it’s an issue at all).

Next I edit my hosts file so that redline.local resolves to my server’s IP address, and I give it a test run by pointing my browser to http://redline.local/redline, which loads up the example redline module provided in the package. And what do I see?

Welcome to Redline

Yay! Next I’ll set up another module and explain what I’ve learned so far about routing.

Trackback

no comment untill now

Add your comment now

You must be logged in to post a comment.