<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>platform agnostic &#187; configuration</title>
	<atom:link href="http://www.deepakg.com/prog/category/configuration/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deepakg.com/prog</link>
	<description></description>
	<lastBuildDate>Wed, 21 Dec 2011 06:32:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Deploying a Perl Dancer application on Amazon EC2</title>
		<link>http://www.deepakg.com/prog/2011/01/deploying-a-perl-dancer-application-on-amazon-ec2/</link>
		<comments>http://www.deepakg.com/prog/2011/01/deploying-a-perl-dancer-application-on-amazon-ec2/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 17:55:39 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=156</guid>
		<description><![CDATA[Dancer is a new Perl web framework that I&#8217;ve been playing with since April. I finally got some time to build a small application and take it live. I chose Amazon&#8217;s EC2 for deployment because in addition to Dancer, that&#8217;s another area which I had been wanting to explore and with their (then) recently introduced &#8230; <a href="http://www.deepakg.com/prog/2011/01/deploying-a-perl-dancer-application-on-amazon-ec2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Dancer is a new Perl web framework that I&#8217;ve been playing with since April. I finally got some time to build a small application and take it live. I chose Amazon&#8217;s EC2 for deployment because in addition to Dancer, that&#8217;s another area which I had been wanting to explore and with their (then) recently introduced free usage tier, there wasn&#8217;t much to lose. Here are some details on how the app was built and deployed:</p>
<h3>Dancer:</h3>
<p><a href="http://stupidtwitterstats.com/">stupidtwitterstats.com</a> pulls out some interesting stats about people you follow on twitter. I use Net::Twitter::Lite to talk to Twitter. I wrote a small class to analyze the data I get from Twitter and that keeps my route clean. I use Template Toolkit for, well, templating. There is a &#8216;lite&#8217; version of Template Toolkit which comes as default with Dancer, but since I&#8217;ve been a TT user (dare I add a power user) for a while now, I went with the real thing.</p>
<p>I initially ran my app using Perl as:</p>
<pre>
perl bin/app.pl
</pre>
<p>I tried enabling &#8220;auto reloading&#8221; of my module so that any changes to it are immediately availble without restarting the app but for some reasons I couldn&#8217;t get it to work consistently on MacOS. A quick note to the Dancer mailing list revealed an alternate solution &#8211; using Plack with the &#8216;shotgun&#8217; loader. The latter reloads your entire app for each request &#8211; a bit like CGI. If you are using modules that tend to have a long start-up time (like Moose), you can also tell plack to not load them every time:</p>
<pre>
plackup -L Shotgun -p 3000 bin/app.pl
</pre>
<p>To prevent certain modules from being reloaded:</p>
<pre>
plackup -MMoose -MDBIx::Class -L Shotgun bin/app.pl
</pre>
<p><a href="http://advent.plackperl.org/2009/12/day-4-reloading-applications.html">This post</a> from the 2009 plack advent calendars has more details.</p>
<h3>Deploying on EC2:</h3>
<p>The biggest problem I had starting with EC2 was documentation. Amazon overwhelms you with a lot of TLAs and their circuitous documentation makes going in circles seem like walking in a straight line (as the diameter of the circle tends to infinity this is indeed how it will feel, but I digress). That said, I came across their <a href="http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/">getting started</a> guide which, alongwith the new web-based management console, made things a breeze.</p>
<p>The next big hurdle was picking the right distro of Linux to deploy on. I have more experience running Debian/Ubuntu in production than any other distro. Canonical&#8217;s 10.04 LTS Server was my first choice. While setting it up was a breeze, logging into it for the first time informed me that I had some pending updates. Installing those updates led me to a point in Grub configuration where the machine just froze. I didn&#8217;t take things any further.</p>
<p>To keep things simple I decided to go with the default Amazon 64-bit Linux instance. Now I would&#8217;ve loved to get hold of their custom Linux build just to replicate the production environment on my machine but Amazon doesn&#8217;t give it out. It looks like it is a Fedora derivative (there are fingerprints all over the place &#8211; e.g. in the welcome page you get when you install niginx) so one could run Fedora and get quite close to the Amazon provided Linux instance.</p>
<p>The Amazon Linux image comes with Perl 5.10.1. My first step was to install the &#8216;Development Tools&#8217; bundle so that I could build things from source if needed. </p>
<pre>
sudo yum groupinstall 'Development Tools'
</pre>
<p>I then installed CPAN Minus (App::cpanminus), which is my preferred tool for installing things off CPAN.</p>
<pre>
sudo cpan App::cpanminus
</pre>
<p>I then used it to get Dancer:</p>
<pre>
sudo cpanm dancer
</pre>
<p>followed by other CPAN dependencies my app had. </p>
<p>At this stage I opened port 80 through the AWS EC2 console and tested my app to make sure it was running fine and was accessible over the internet using the temporary Amazon supplied domain name. I then got an Elastic IP and tied it to my running machine instance. I also went to my domain registrar (Dreamhost) and pointed my domain&#8217;s A record to this IP.</p>
<p>My next step was to install the Starman web-server under which my application is deployed.</p>
<pre>
sudo cpanm starman
</pre>
<p>I ran my app again &#8211; this time under Starman and checked it over the internet to make sure that everything was fine so far:</p>
<pre>
sudo /usr/local/bin/plackup -s Starman -p 80 -E deployment --workers=10 \
 -a /home/apps/TwitterToys/bin/app.pl
</pre>
<p>Satisfied, I moved on to the next big step &#8211; installing and configuring nginx. While ideally I would&#8217;ve loved to install the latest 0.8.x branch of nginx, it wasn&#8217;t available out of the box on Amazon&#8217;s Linux image. Indeed, even the most recent Linux distros (Ubuntu 10.04 Server or Debian Lenny/Squeeze) seem to give it a miss. While nginx compiles from source on most distros without problems, keeping it updated, patched and running can be daunting. So I settled for the default 0.7.67 install via yum:</p>
<pre>
sudo yum install nginx
</pre>
<p>I use nginx to do all the HTTP related stuff like gzipping content, serving static files, adding the right expires header and so on. It also acts as a caching proxy in my setup. Dancer running under Starman/Plack does everything else.</p>
<p>The following lines setup gzip response compression and a caching zone:</p>
<pre>
http {
    ..
    ..
    ..
    gzip on;
    gzip_min_length 1024;

    proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=twitter:8m
max_size=64m inactive=60m;
    proxy_temp_path /tmp;
    proxy_cache_key "$scheme://$host$request_uri";
    proxy_cache_valid 200 60m;
	..
	..
	..
</pre>
<p>I then setup the server to proxy the requests to my running Dancer instance:</p>
<pre>
  server {
        server_name stupidtwitterstats.com;
        listen       80;

        location / {
            proxy_cache twitter;

            #bypass cache for this path so that I can check my API usage
            set $do_not_cache 0;

            if ( $request_uri ~ "^/xyz$" ) {
                 set $do_not_cache 1;
            }
            proxy_no_cache $do_not_cache;
            proxy_pass http://127.0.0.1:5001;
            proxy_redirect http://127.0.0.1:5001/ http://$host/;
            expires 1h;
        }
</pre>
<p>I also setup another location block within the same server block to let nginx serve all the images directly:</p>
<pre>
        location /images/ {
            alias /home/apps/TwitterToys/public/images/;
            expires 30d;
            access_log off;
        }
</pre>
<p>I fired up Starman again &#8211; this time on port 5001 and bound to 127.0.0.1 and tested nginx from the internet to make sure that everything was working fine. I did run into a problem with serving static content. A look at the error log (/var/log/nginx/error.log) showed that nginx worker process was running into a permission issue reading the files:</p>
<pre>
2011/01/02 07:01:39 [error] 3781#0: *1 open()
"/home/apps/TwitterToys/public/images/logo.png" failed
(13: Permission denied), client: 122.167.81.253, server: _,
request: "GET /images/logo.png?x=1 HTTP/1.1", host:
</pre>
<p>I gave &#8216;others&#8217; read and execute permissions on the /home/apps/ folder to make sure that nginx worker process could get in and read the files and the &#8217;13: Permission denied&#8217; errors went away.</p>
<pre>
sudo chmod -R o+rx /home/apps
</pre>
<p>This brought me to the last big task &#8211; configuring my Dancer application to run as a daemon so that it runs in the background and comes up when the OS boots the next time. I chose Daemontools for this. Unfortunately Daemontools were not available on Amazon&#8217;s Linux image via yum (they are available on Ubuntu 10.04 via the default repositories using apt-get), so I decided to roll pull the source and build. Here, I ran into another wall &#8211; the compilation would stop with some vague reference to errno.h. After some tense moments of frantically searching the internet, I found that I had to modify error.h in the src/ directory of the daemontools source distribution to something like this:</p>
<pre>
/* extern int errno; */
#include &lt;errno.h&gt;
</pre>
<p>The compilation and subsequent installation went fine. I restarted my EC2 instance to make sure that &#8216;svscan&#8217; came up after the reboot. Things were much simpler this point on. All I had to do was create a folder for my daemon (I called it TwitterToys) under /service and place a shell script called &#8216;run&#8217; with execute bit set:</p>
<pre>
#!/bin/sh

export PERL5LIB='/home/apps/TwitterToys/lib'
exec 2>&#038;1 \
/usr/local/bin/plackup -s Starman -l 127.0.0.1:5001 -E deployment \
--workers=10 -a /home/apps/TwitterToys/bin/app.pl
</pre>
<p>Within moments my new and shiny daemon came up. I did another reboot to make sure that it indeed does come up as expected. By this time my domain changes had replicated to my ISP and pointing my browser http://stupidtwitterstats.com brought up my site. </p>
<p>My last steps before announcing it to the world were:</p>
<p>1. to add a CNAME record for &#8216;www&#8217; pointing to stupidtwitterstats.com so that people who prefix URLs with www do make it to my site. </p>
<p>2. to add the following server block to my nginx configuration so that www.stupidtwitterstats.com redirects to stupidtwtterstats.com (<a href="http://aleksandarsavic.com/nginx-redirect-wwwexamplecom-requests-to-examplecom-or-vice-versa/">via</a>)</p>
<pre>
    server {
        server_name www.stupidtwitterstats.com;
	rewrite ^(.*) http://stupidtwitterstats.com$1 permanent;
    }
</pre>
<p>There you have it! A site running on Perl and Dancer from start to finish.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2011/01/deploying-a-perl-dancer-application-on-amazon-ec2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing VMWare tools on Debain Lenny/Etch</title>
		<link>http://www.deepakg.com/prog/2009/09/installing-vmware-tools-on-debain-lennyetch/</link>
		<comments>http://www.deepakg.com/prog/2009/09/installing-vmware-tools-on-debain-lennyetch/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 19:26:38 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=74</guid>
		<description><![CDATA[If you are building an X-less command-line-only Debian VM, here is what you&#8217;ll need to do in order to install VMWare tools so that you can use features like shared folders: 1. Login as root or su. 2. Make sure you have installed the kernel sources and build tools. apt-get install build-essential Then run: apt-get &#8230; <a href="http://www.deepakg.com/prog/2009/09/installing-vmware-tools-on-debain-lennyetch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are building an X-less command-line-only Debian VM, here is what you&#8217;ll need to do in order to install VMWare tools so that you can use features like shared folders:</p>
<p>1. Login as root or su.<br />
2. Make sure you have installed the kernel sources and build tools. </p>
<p><code>apt-get install build-essential</code></p>
<p>Then run:</p>
<p><code>apt-get install linux-headers</code></p>
<p>This will probably give you a message saying: &#8220;Package linux-headers is a virtual package provided by:&#8221;, followed by a list of available kernel versions. Choose your version by looking it up:</p>
<p><code>cat /proc/version</code></p>
<p>or</p>
<p><code>uname -a</code></p>
<p>e.g. in my case I chose:</p>
<p><code>apt-get install linux-headers-2.6-2-amd64</code></p>
<p>3. Next choose Virtual Machine -> Install VMWare Tools option from the menu (this assumes VMWare Fusion running on Mac but there should be a similar option for VMWare Workstation on Linux and Windows as well).</p>
<p>Now mount the VMWare tools virtual CD:</p>
<p><code><br />
mount /cdrom<br />
cd /cdrom<br />
</code></p>
<p>Copy VMWare tool source code to /tmp and extract the files (the actual filename will depend on your VMWare version [which the VMWare installer would have reported in case of a mismatch]):</p>
<p><code>cp VMWareTools-7.9.6-173382.tar.gz /tmp<br />
cd /tmp<br />
tar -xzvf VMWareTools-7.9.6-173382.tar.gz<br />
</code></p>
<p>At this stage you should have a folder called vmware-tools-distrib inside your /tmp folder. Visit this folder and run vmware-install.pl, then follow the on-screen instructions.</p>
<p><code>cd /tmp/vmware-tools-distrib<br />
./vmware-install.pl<br />
</code></p>
<p>Now at one stage the VMWare tool installer complained about my installed gcc (4.3) version being different from the gcc version that was used to compile my kernel (4.1). Press Ctrl+C to abort the installer at this stage. </p>
<p>Turns out that gcc is merely a symbolic link in /usr/bin folder. Chances are that you&#8217;ll have 2 versions of gcc on your system (e.g. Lenny comes with /usr/bin/gcc-4.3 and /usr/bin/gcc-4.1). Just make the symlink point to the version of gcc that was used to compile your kernel:</p>
<p><code>cd /usr/bin<br />
rm gcc<br />
ln -s /usr/bin/gcc-4.1 gcc<br />
</code></p>
<p>Run vmware-install.pl again and this time things should go through. Restart your VM to finish the installation. You should now be able to see folders shared from the host machine under /mnt/hgfs.</p>
<p>Most of these steps should also apply to Ubuntu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2009/09/installing-vmware-tools-on-debain-lennyetch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install and enable Apache2::Request on Ubuntu Server 8.10</title>
		<link>http://www.deepakg.com/prog/2009/01/install-and-enable-apache2request-on-ubuntu-server-810/</link>
		<comments>http://www.deepakg.com/prog/2009/01/install-and-enable-apache2request-on-ubuntu-server-810/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 16:40:17 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Apache2::Request]]></category>
		<category><![CDATA[libapreq2]]></category>
		<category><![CDATA[mod_apreq2]]></category>
		<category><![CDATA[mod_perl]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=39</guid>
		<description><![CDATA[A mod_perl handler can parse the incoming client request (querystring, form post data etc) using Apache2::Request. It is *not* installed when you install mod_perl. Getting it working is a 3 step process. First issue the following command: sudo apt-get install libapreq2 This installs 2 things &#8211; the libapreq2 shared library, and an Apache module &#8211; &#8230; <a href="http://www.deepakg.com/prog/2009/01/install-and-enable-apache2request-on-ubuntu-server-810/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A mod_perl handler can parse the incoming client request (querystring, form post data etc) using Apache2::Request. It is *not* installed when you install mod_perl. Getting it working is a 3 step process. </p>
<p>First issue the following command:</p>
<p><code>sudo apt-get install libapreq2</code></p>
<p>This installs 2 things &#8211; the libapreq2 shared library, and an Apache module &#8211; mod_apreq2.</p>
<p>Next we install the Perl bindings &#8211; Apache2::Request &#8211; which we use in our handler code. </p>
<p><code>sudo apt-get install libapache2-request-perl</code></p>
<p>At this stage if you restart Apache, it will load your Perl handler without any complaints. However if you visit a handler that uses Apache2::Request, it&#8217;ll error out with the following entry in error.log:</p>
<p><code><br />
/usr/sbin/apache2: symbol lookup error: /usr/lib/perl5/auto/APR/Request/Apache2/Apache2.so: undefined symbol: apreq_handle_apache2<br />
</code></p>
<p>This is because unlike <a href="http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/">our mod_perl installation</a>, apt-get doesn&#8217;t enable mod_apreq2 after installing it. We enable it manually by creating a symbolic link to /etc/apache2/mods-available/apreq.load under /etc/apache2/mods-enabled/:</p>
<p><code><br />
sudo bash<br />
cd /etc/apache2/mods-enabled<br />
ln -s ../mods-available/apreq.load<br />
apache2ctl restart<br />
</code></p>
<p>Updated: You can also run a2enmod to enable an Apache module and use a2dismod to disable it.</p>
<p>Visit your handler url again and this time it should work withour errors. Here is the modified handler from the <a href="http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/">mod_perl installation post</a> that now uses Apache2::Request to enable you to test if your installation is working correctly:</p>
<pre>
package Hello;
use strict;

use Apache2::RequestRec ();
use Apache2::RequestIO ();

use Apache2::Const -compile => qw(OK);

use Apache2::Request;

sub handler {
    my $r = shift;

    $r->content_type('text/plain');

    my $req = Apache2::Request->new($r);
    my $name = $req->param("name");
    $name = $name ? $name : "World";

    print "Hello $name, the time here is " . localtime() . "\n";

    return Apache2::Const::OK;
}

1;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2009/01/install-and-enable-apache2request-on-ubuntu-server-810/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing mod_perl on Ubuntu Server 8.10</title>
		<link>http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/</link>
		<comments>http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 18:59:41 +0000</pubDate>
		<dc:creator>deepakg</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_perl]]></category>

		<guid isPermaLink="false">http://www.deepakg.com/prog/?p=8</guid>
		<description><![CDATA[I am at a stage in life where I am going to be writing a lot of Perl code again. My preferred OS is Mac OS since it already comes with Perl 5.8.8 and Apache 2.2.9 (as of Mac OS 10.5.6). Unfortunately, mod_perl that ships with Mac OS, is broken (segfaults!). You can use fink &#8230; <a href="http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am at a stage in life where I am going to be writing a lot of Perl code again. My preferred OS is Mac OS since it already comes with Perl 5.8.8 and Apache 2.2.9 (as of Mac OS 10.5.6). Unfortunately, mod_perl that ships with Mac OS, is broken (segfaults!). You can use fink or macports to pull Apache/Perl/mod_perl that work but I figured that if I use Ubuntu, I also get to be close to my Debian production environment. Here is how I got a fresh Ubuntu 8.10 Server VM ready with mod_perl:</p>
<h5>Getting started</h5>
<p>At one stage during the installation of Ubuntu server, you&#8217;ll be asked what components you want installed. Pick LAMP at the very least. After booting up for the first time (and logging in), fire up the following commands:<br />
<code><br />
sudo bash #fire up a root shell so that we don't have to sudo every command<br />
apt-get update<br />
apt-get dist-update<br />
reboot</code></p>
<p><code> </code></p>
<p><code>#install things that could come in handy later<br />
sudo bash<br />
apt-get emacs #skip this if you prefer vi - it's already there<br />
apt-get install linux-headers-server build-essential<br />
</code></p>
<p>At this stage you&#8217;ll have the latest kernel running. I find the default 80&#215;24 display a little too restrictive. We&#8217;ll fix that by editing <code>/boot/grub/menu.lst</code>. Open the file in emacs or whatever editor you like, and scroll down to the end to a bunch of options that look like title, uuid, kernel, initrd. Append vga=0x31A to the end of the first kernel statement. e.g. in my case<br />
<code><br />
kernel		/boot/vmlinuz-2.6.27-9-server root=UUID=d9f9cc35-d880-494d-8cd3-92da418a438b ro quiet splash<br />
</code></p>
<p>became<br />
<code><br />
kernel		/boot/vmlinuz-2.6.27-9-server root=UUID=d9f9cc35-d880-494d-8cd3-92da418a438b ro quiet splash <strong>vga=0x31A</strong><br />
</code></p>
<p>Reboot.</p>
<p>vga=0x31A gives me a resolution of 1280&#215;1024 and 64k colors. Here are other options that you can play with:</p>
<pre>#  FRAMEBUFFER RESOLUTION SETTINGS
#     +-------------------------------------------------+
#          | 640x480    800x600    1024x768   1280x1024
#      ----+--------------------------------------------
#      256 | 0x301=769  0x303=771  0x305=773   0x307=775
#      32K | 0x310=784  0x313=787  0x316=790   0x319=793
#      64K | 0x311=785  0x314=788  0x317=791   0x31A=794
#      16M | 0x312=786  0x315=789  0x318=792   0x31B=795
#     +-------------------------------------------------+</pre>
<h5>Installing mod_perl</h5>
<p>At this stage we already have Apache and Perl installed. If you do:<br />
<code>tail /var/log/apache2/error.log</code>, you&#8217;ll see that out of the box, you only get support for PHP.<br />
<code><br />
[Sun Dec 14 12:04:05 2008] [notice] Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch configured -- resuming normal operations<br />
</code></p>
<p>Here is how you add mod_perl support:</p>
<p><code><br />
sudo bash<br />
apt-get install libapache2-mod-perl2</code></p>
<p><code>#restart apache so that it loads mod_perl<br />
apache2ctl restart</p>
<p>#make sure that it did indeed load<br />
tail /var/log/apache2/error.log</p>
<p></code></p>
<p><code>#if all went well, you'll see something to the effect of (emphasis mine):<br />
[Sun Dec 14 12:19:17 2008] [notice] Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch <strong>mod_perl/2.0.4 Perl/v5.10.0</strong> configured -- resuming normal operations<br />
</code></p>
<h5>Testing our mod_perl installation</h5>
<p>Let&#8217;s write a simple mod_perl response handler to make sure our installation was successful. Create Hello.pm in your home directory &#8211; which is <code>/home/deepakg/</code> on my machine:</p>
<pre>package Hello;
use strict;

use Apache2::RequestRec ();
use Apache2::RequestIO ();

use Apache2::Const -compile =&gt; qw(OK);

sub handler {
    my $r = shift;

    $r-&gt;content_type('text/plain');
    print "Hello World, the time here is " . localtime() . "\n";

    return Apache2::Const::OK;
}

1;</pre>
<p>Then to make sure that we didn&#8217;t make any typos:<br />
<code><br />
perl -c Hello.pm<br />
Hello.pm syntax OK<br />
</code></p>
<p>Next, open <code>/etc/apache2/apache2.conf</code> and type the following right at the end:</p>
<pre>PerlRequire /home/deepakg/Hello.pm
&lt;Location /time&gt;
   SetHandler perl-script
   PerlResponseHandler Hello
&lt;/Location&gt;</pre>
<p>Restart apache and check the Apache error log to make sure that it started without any issues:<br />
<code><br />
sudo apache2ctl restart<br />
tail /var/log/apache2/error.log<br />
</code></p>
<p>Install lynx, so that you can check your handy work:<br />
<code><br />
sudo apt-get install lynx</code></p>
<p><code> </code></p>
<p><code># and once it is installed<br />
lynx http://localhost/time<br />
</code></p>
<p>If everything is working then you&#8217;ll be greeted with something like this:<br />
<code><br />
Hello World, the time here is Sat Jan 10 15:25:51 2009<br />
</code><br />
Of course, the actual date and time will vary on your system <img src='http://www.deepakg.com/prog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h5>Miscellaneous</h5>
<p>If the time shown by the script above looks awkward, your time zone might not have been configured correctly. Configure the time zone to where you are:<br />
<code><br />
sudo dpkg-reconfigure tzdata<br />
</code></p>
<p>And then may be tweak the clock by hand if needed:<br />
<code><br />
sudo date MMDDhhmm #MM - month, DD - date, hh - hour (24 format), mm - minute<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepakg.com/prog/2009/01/installing-mod_perl-on-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.231 seconds -->

