7
Mar/09
0

Building Apache and Mod Perl on Mac OS X

I’ve finally had my work laptop upgraded to Leopard!!! :)

As such, I’ve just spent the last couple of days getting things all set-up nicely so that I can get on with my work. Most of the work that I do is web development orientated, and mainly using Perl and Catalyst, so an install of Apache and mod_perl is needed.

OS X does come with a complete install of Apache (even with mod_perl!) out of the box and ready to go (info on using this set-up can be found here), but I’m also working on another project that may involve the use of Jaxer, and this requires a newer build of Apache than the one shipped with Leopard. :(

Thankfully building these tools isn’t too complicated, here’s a quick dump of my notes on getting this done. Note, I’m installing them into /usr/local so that I don’t mess with any of the OS X internals that I shouldn’t be touching - this is completely removable.

First, make a work area for building:

sudo mkdir -p /usr/local/src
sudo chgrp admin /usr/local/src
sudo chmod -R 775 /usr/local/src
cd /usr/local/src

Apache

curl -O http://apache.mirror.infiniteconflict.com/httpd/httpd-2.2.11.tar.gz
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11

Now here’s the big one - the Apache configuration. This compiles a heap of modules I probably don’t need, but it’s nice to have them there in case I do ever need them…

CFLAGS="-O3" CXXFLAGS="-O3" \
./configure --prefix=/usr/local/apache2 \
--enable-autoindex \
--enable-cache \
--enable-cgi \
--enable-deflate \
--enable-dir \
--enable-disk_cache \
--enable-fastcgi \
--enable-file_cache \
--enable-headers \
--enable-include \
--enable-info \
--enable-log_config \
--enable-log_forensic \
--enable-logio \
--enable-mem_cache \
--enable-mime \
--enable-mime_magic \
--enable-negotiation \
--enable-perl \
--enable-proxy \
--enable-proxy-balancer \
--enable-proxy-http \
--enable-rewrite \
--enable-speling \
--enable-status \
--enable-suexec \
--enable-userdir \
--enable-usertrack \
--enable-version \
--enable-vhost_alias \
--enable-so \
--enable-mods-shared=all

Then the standard make and install:

make
make test
sudo make install

Now to add some configuration so that Apache starts on system boot, first we need to create a startup script:

cd /System/Library/StartupItems/
sudo mkdir Apache
cd Apache
sudo touch Apache
sudo chmod a+x Apache
mate Apache

Paste this content into the file:

#!/bin/sh
 
##
# Apache HTTP Server
##
 
. /etc/rc.common
 
StartService () {
	ConsoleMessage "Starting Apache web server"
	/usr/local/apache2/bin/apachectl start
}
 
StopService () {
	ConsoleMessage "Stopping Apache web server"
	/usr/local/apache2/bin/apachectl stop
}
 
RestartService () {
	ConsoleMessage "Restarting Apache web server"
	/usr/local/apache2/bin/apachectl restart
}
 
RunService "$1"

Then a configuration file:

sudo touch StartupParameters.plist
mate StartupParameters.plist

Paste this content into the file:

{
  Description     = "Apache web server";
  Provides        = ("Web Server");
  Requires        = ("DirectoryServices");
  Uses            = ("Disks","Network Time");
  OrderPreference = "None";
}

Then reboot and open up http://localhost to make sure things have worked.

Mod Perl

This is a lot more straight forward:

cd /usr/local/src
curl -O http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz
tar zxvf mod_perl-2.0-current.tar.gz
cd mod_perl-2.0.4
perl Makefile.PL MP_AP_PREFIX=/usr/local/apache2
make
make test
sudo make install

Now all you have to do is add the following line to your Apache httpd.conf (/usr/local/apache2/conf/httpd.conf) with all of the LoadModule entries:

LoadModule perl_module modules/mod_perl.so

All done! :)

Tagged as: , ,
27
Nov/07
0

Ack, a Grep Replacement

Ack is a grep alternative, written in pure Perl, using Perl’s regular expressions to do your searches (just one of the long list of reasons to use this over grep). I think i’ll be using this then…

ack is a tool like grep, aimed at programmers with large trees of heterogeneous source code. ack is written purely in Perl, and takes advantage of the power of Perl’s regular expressions.

via

1
Nov/07
7

Adding/Deleting Rows in TableKit Tables Revisited

TableKit is a great javascript library for making your HTML tables fully editable. However, one problem is that you can’t add or delete rows from the tables…

I came up with a solution to this not so long ago, but it still had a problem - TableKit caches the tables on loading, so after we update the table body (adding or deleting a row) the sorting and editing of the table is completely screwed! :( However, with a little more work, and some help from one of the guys in the office - we’ve finally got this cracked! :)

19
Oct/07
0

Visualizing Your DBIC Schema

What a great idea - will give this a bash next week…

If you want a somewhat pretty picture of your DBIC schema (with relationships drawn, of course), install GraphViz, SQL::Translator, and DBICx::Deploy from the CPAN, and then run:

$ dbicdeploy -Ilib MyApp::Schema ~/graphs GraphViz

~/graphs will then contain a .sql file that is actually a png of your schema. Rename it and see your schema in your favorite png viewing application.

via

18
Oct/07
0

Remove Case-Sensitivity in Oracle

Oracle is a great RDBMS, but the fact that searches against the database are case-sensitive can be a pain in the butt. Here’s how you can make searches case-insensitive…

11
Oct/07
0

Adding/Deleting Rows in TableKit Tables

This post has now been updated. Please head over to the new post for something better…

Following on from my previous post on how to integrate the excellent TableKit into your Catalyst webapp (to make your data tables dynamically editable), here’s how i’ve gone about adding ajax inserts and deletes so that you can add and remove data rows in your tables.1


  1. You’ll need the code from the previous post to follow along. 

10
Oct/07
0

Some Useful Catalyst Tips

Found this small selection of tips that can come in use whilst working with Catalyst…

read more

23
Sep/07
1

Making Editable Tables With Catalyst and TableKit

Catalyst is an MVC web-development framework for Perl, very similar in concepts, ideas (and even some of the implementation) to Ruby on Rails. I’m using Catalyst a lot in my job now, and one of the first challenges that i’ve had to go through is making dynamically editable tables for some of the views we are using (in other words, Ajax driven edit-in-place tables).

Following a short Google, there seemed to be only two ready-made options I could see: one, using the Catalyst controller module Catalyst::Controller::ROSE::EIP; or two, by integrating and using the stand-alone javascript package TableKit.