Next Image
Make the current image sticky.
Previous Image
randys.org - randys.org

Posts Tagged ‘mysql’

LiMP: Lighttpd, MySQL & PHP on OS X

In following with the LAMP, MAMP, and WAMP themes, I’ve come up with my own acronym: LiMP. Lighttpd, MySQL, PHP. Of course, this doesn’t really follow the conventions of the other acronyms (my OS isn’t represented). Mainly because adding an ‘M’ just doesn’t sound (or look) right. It’s a great setup and I recently reconfigured it so it’s a (somewhat) isolated installation that could potentially be installed on any OS X system. I also managed to get ExecWrap working properly as well.

*NB* This is a fairly technical article and requires getting your fingers dirty in the Terminal (a.k.a. comman line). If you’re not fully comfortable in the Terminal, I suggest you familiarize yourself with the Terminal. You’ll also need to have installed the latest version of Xcode.

You can build this just about anywhere on your system you like. I personally keep everything in

/usr/local/src
but you can build this anywhere you want on your system. I also like to
sudo -s
so that I’m always root when comiling and installing these things. Let’s jump in…

Create your src directories:

mkdir -p /usr/local/src && cd /usr/local/src

That’s it. Now lets dig in…

Setting up Lighttpd on OS X

I figured building this on OS X wouldn’t take too much effort and I was pretty much right. Lighttpd builds just fine on OS X but it does need some other libraries installed for certain functionality. Specifically, fastcgi and Perl Compatible Regular Expressions. These libraries install without issue as well.

First lets grab the fastcgi libraries:

curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar zxvf fcgi-2.4.0.tar.gz && cd fcgi-2.4.0
./configure
make
make install
cd ..

Now lets get the PCRE libraries:

curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-5.0.tar.gz
tar zxvf pcre-5.0.tar.gz && cd pcre-5.0
./configure
make
make install
cd ..

Now for lighttpd:

curl -O http://www.lighttpd.net/download/lighttpd-1.4.12.tar.gz
tar zxvf lighttpd-1.4.12.tar.gz && cd lighttpd-1.4.12
./configure --prefix=/Library/limp/lighttpd

Hopefully, you’ll see something like this after the configure script is done.

Plugins:

mod_rewrite : enabled mod_redirect : enabled mod_ssi : enabled mod_cgi : enabled mod_fastcgi : enabled mod_proxy : enabled mod_evhost : enabled mod_simple_vhost: enabled mod_mysql_vhost : enabled mod_access : enabled mod_alias : enabled mod_setenv : enabled mod_usertrack : enabled mod_compress : enabled mod_auth : enabled mod_status : enabled mod_accesslog : enabled mod_rrdtool : enabled mod_secdownload : enabled mod_expire : enabled

If you don’t see mod_fastcgi in there, something went south.

make
make install
cp doc/lighttpd.conf /Library/limp/lighttpd/lighttpd.conf

MySQL

For MySQL, I just used the standard binary installation provided by MySQL. Therefore, we’ll need to also configure and install the libraries after installing the binary package. (Thanks to Richard Valk for his article series for this bit).

First, download and install MySQL (version 5.0.24a as of this writing) Standard binary for OS X for your platform (PPC or Intel). Once you’ve installed the package, install the StartupItem and make your life simple-er (??). After everything is setup, you should modify your

PATH
environment variable again in your ~/.bashrc file.

export PATH="/usr/local/bin:/usr/local/mysql/bin:"${PATH}

Now we have to rebuild mysql and install the shared libraries we need for building PHP. Make sure you’re still in your ‘src’ directory.

curl -O http://www.stathy.com/mysql/Downloads/MySQL-5.0/mysql-5.0.24.tar.gz
tar zxvf mysql-5.0.24.tar.gz && cd mysql-5.0.24
./configure --prefix=/usr/local/mysql \
 --localstatedir=/usr/local/mysql/data \
 --libexecdir=/usr/local/mysql/bin \
 --libdir=/usr/local/mysql/lib \
 --with-server-suffix=-standard \
 --enable-thread-safe-client \
 --enable-local-infile \
 --enable-shared \
 --with-zlib-dir=bundled \
 --with-big-tables \
 --with-readline \
 --with-archive-storage-engine \
 --with-innodb \
 --without-docs \
 --without-bench \
make
make install
cd ..

Compiling PHP on OS X (with the mysqli extension)

This was fairly straight forward with the exception of GD. It took me a while to figure this out, but I was using

--with-gd=/sw
and this was confusing the compiler for some reason. When I changed it to just
--with-gd
everything compiled fine… including the mysqli extension. Here’s what my config looks like:

./configure \
 --prefix=/Lbrary/limp/php \
 --enable-fastcgi \
 --enable-force-cgi-redirect \
 --enable-mbstring \
 --with-xml \
 --with-zlib \
 --with-curl \
 --with-mysql=/usr/local/mysql \
 --with-pdo-mysql=/usr/local/mysql \
 --with-mysqli=/usr/local/mysql/bin/mysql_config \
 --with-pdo-sqlite \
 --with-sqlite \
 --with-mcrypt=/sw \
 --with-gd \
 --with-jpeg-dir=/sw \
 --with-png-dir=/sw \
 --with-zlib-dir=/sw \
 --with-xpm-dir=/usr \
 --enable-exif \
 --enable-ftp \
 --enable-libxml \
 --enable-soap \
 --enable-sockets

make && make install cp /Library/limp/php/bin/php /Library/limp/php/bin/php-cgi

I’m renaming the php binary to php-cgi because, well, that’s what it is. It’s the CGI version, not the CLI version. If you want to compile the CLI version, replace

 --enable-fastcgi \
 --enable-force-cgi-redirect \

with

 --enable-cli \

and run

make && make install
again. Only do this after you’ve renamed the php file to php-cgi. Otherwise, you’ll overwrite the cgi version with the cli version and it won’t work with fastcgi.

Building ExecWrap


I’ll have to finish this at a later date… sorry. This was originally posted to my old WordPress blog as a Draft but got imported into Typo via the wordpress2.rb script as a published article… so I left it.

• • •

All content Copyright © 1999 — 2010 Randy Sesser | Happily Hosted by WebFaction
Entries (RSS) | Comments (RSS)