<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Tom Gidden &#187; apache</title>
	<atom:link href="http://gidden.net/tom/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://gidden.net/tom</link>
	<description></description>
	<lastBuildDate>Sun, 01 May 2011 10:35:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MySQL and PDO on OS X Leopard, Intel</title>
		<link>http://gidden.net/tom/2008/06/30/mysql-and-pdo-on-os-x-leopard-intel/</link>
		<comments>http://gidden.net/tom/2008/06/30/mysql-and-pdo-on-os-x-leopard-intel/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 14:35:05 +0000</pubDate>
		<dc:creator>Tom Gidden</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Techie]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[dbd::mysql]]></category>
		<category><![CDATA[dbi]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[Mac-OS-X]]></category>
		<category><![CDATA[OS-X]]></category>
		<category><![CDATA[pdo]]></category>
		<category><![CDATA[pdo_mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[universal]]></category>

		<guid isPermaLink="false">http://gidden.net/tom/?p=53</guid>
		<description><![CDATA[(NOTE: Make sure you read the comments for this post, as there's a better way to get around the 64-bit/32-bit problem without having to compile things. --Tom)

I don't know if I'm missing something big, but getting Perl, Apache, PHP, PDO and MySQL to play nice on my Mac OS X 10.5 install on my Intel Core 2 Duo (Penryn) MacBook Pro hasn't been easy.  This is partly thanks to Apache being compiled with x86_64 support, and Perl with i386 only.
Anyway, Googling about, I notice that others have tried this arrangement with varying degrees of success.  The easy answer is to install something like MAMP or replace the Apache and PHP installation with a custom build.
However, I prefer to keep my installation as stock as possible, and I'm not a huge fan of proprietary packaging systems like MacPorts and Fink.  Don't get me wrong: those systems do what they're meant to do, and as a long-time FreeBSD user, I appreciate the approach.  However, they don't fit into the Mac mindset too well, plus I'm too lazy to keep them up-to-date.
In other words, I want Apple to do it all for me, via Software Update where possible.  The aim is to keep the stock Apache, PHP and Perl in place, and just add stuff.
The 10.5.3 Apache install does include PDO, but it's fairly crippled: the only drivers are the SQLite ones, even though standard "mysql" support is included.  So, "pdo_mysql" will need to be installed... no problem: just install it as a module.  But which architecture?
Since 10.5.3 Apache is compiled for i386 and x86_64, it'll run by default as 64-bit, requiring the 64-bit MySQL client libraries.
However, the included 10.5.3 Perl build is compiled only for i386, so if you want to build DBD::mysql for Perl as well, you'll need 32-bit MySQL client libraries.
The MySQL 5.1 official Leopard binary isn't currently a universal build, so right now if you download a binary distribution, you have to pick either 32-bit i386, or 64-bit x86_64.  This will knacker either PHP/PDO (64-bit) or Perl/DBI (32-bit)  So, assuming we don't want to replace -- or otherwise mess with -- the stock Apache, Perl and PHP, recompiling MySQL seems the way to go: we need to build a fat MySQL with both architectures.
To do this, download the MySQL source (I'm using 5.1.25), unzip and compile with something like:

MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-O3 -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure \
'--disable-dependency-tracking' \
'--prefix=/usr/local/mysql' \
'--localstatedir=/usr/local/mysql/data' \
'--libexecdir=/usr/local/mysql/bin' \
'--with-comment=MySQL Community Server (GPL)' \
'--enable-thread-safe-client' \
'--enable-local-infile' \
'--with-big-tables'

make

sudo make install

You'll then probably want to do something like:

sudo -s

cd /usr/local

export MYSQL_VERSION=mysql-`mysql/bin/mysql_config --version`-osx10.5-universal

mv mysql $MYSQL_VERSION

ln -s $MYSQL_VERSION mysql

chown -R _mysql:staff $MYSQL_VERSION

cd mysql

ln -s share/mysql support-files

ln -s var data

bin/mysql_install_db --user=_mysql

I'm not sure whether this is the right procedure, but it works for me.  A lot of this will change depending on your requirements and circumstances, so don't blame me if it kills your pets.
Next up is to install the PDO_mysql module.  This is easy. Firstly, download the PHP source.  As of Mac OS X 10.5.3, the current PHP is 5.2.5, but I downloaded 5.2.6 and it seemed fine.  Unzip it, and go into the distribution directory (ie. php-5.2.6)
Then:

cd ext/pdo_mysql

phpize

MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-O3 -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
./configure --prefix=/usr --with-pdo-mysql=/usr/local/mysql

make

sudo make install

You might need to add the following line to /etc/php.ini (creating that file, if necessary):

extension=pdo_mysql.so

Then, restart Apache and you should have a working PDO_mysql driver.
Installing DBD::mysql for the stock Perl is a different matter.  If you just do a CPAN install, then the multiple -arch tags that the mysql_config from your new Universal build of MySQL will return are going to foul it up.  So instead, you can just build DBD::mysql for i386, as Perl is going to be running in 32-bit mode anyway.
There are probably better, easier ways of doing this, but I resorted to just doing a manual DBD::mysql build, stating the flags by hand:

perl Makefile.PL \
 --cflags="-I/usr/local/mysql/include/mysql -Os -arch i386 -fno-common" \
 --libs="-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm"

make

sudo make install
]]></description>
		<wfw:commentRss>http://gidden.net/tom/2008/06/30/mysql-and-pdo-on-os-x-leopard-intel/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>.htaccess, mod_rewrite on GoDaddy</title>
		<link>http://gidden.net/tom/2006/05/26/4/</link>
		<comments>http://gidden.net/tom/2006/05/26/4/#comments</comments>
		<pubDate>Fri, 26 May 2006 14:01:48 +0000</pubDate>
		<dc:creator>Tom Gidden</dc:creator>
				<category><![CDATA[Techie]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[htaccess_file]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[nucleus-cms]]></category>
		<category><![CDATA[rewriterule]]></category>

		<guid isPermaLink="false">http://gidden.net/tom/?p=4</guid>
		<description><![CDATA[Even though GoDaddy supports mod_rewrite, there are some definite peculiarities about their setup, with regards to .htaccess and PHP execution. Hopefully the observations I've made in this article will be of help if you're coming across the same problems I was.

UPDATE [9/Jul/2006]: .htaccess changes seem to be taking effect immediately now, at least for me.
UPDATE [3/Dec/2007]: According to comments left below, this is still an issue.  I can't verify, though, as I stopped using GoDaddy ages ago.  I've restored the stricken text, but please don't assume this information is still correct, as Your Mileage May Vary.
I was trying to set up Nucleus CMS and was having a little trouble with setting up the whole permalink / fancy URLs thing.  In particular, the mod_rewrite stuff in .htaccess didn't seem to be working correctly.
Googling for htaccess rewriterule godaddy tells me that I'm not the only one who was having issues.
I managed to get it working, and there are a few things to note:

Changes to the .htaccess file DO NOT TAKE IMMEDIATE EFFECT: I got very frustrated whem my rules were seemingly ignored, until I noticed that rules I deleted still worked.  So, after making a cup of tea, I came back to find they all worked. I'm pretty sure this is the problem most people are having.
Requests for PHP files (eg. http://gidden.net/tom/item.php) are intercepted well before .htaccess (and definitely mod_rewrite) activate. So, mod_rewrite will not work on URLs for PHP files.
However, it will allow redirections to PHP files.

Like many of GoDaddy's services, the changes aren't instant: when you change a setting in the hosting manager, it often takes 10-15 minutes to happen. At one extreme, I moved the hosting package to another (non-existent) domain while shuffling things around, and it took 24 hours before it would let me change it back.
I think they must have a weird form of file distribution where the FTP servers are not talking to the same filesystem as the webservers, and a cron job performs some sort of mirroring.  Either that, or there's some caching that doesn't get cleared correctly.
The fact that PHP files bypass .htaccess makes me think that PHP requests are separated out (possibly by some load-balancer or other magic box) and run on a different server.  It's clear that PHP is run through the CGI/FastCGI mechanism, rather than the more usual mod_php/apache way, but I wouldn't necessarily expect a large-scale shared hosting site to use mod_php.  It's a slight inconvenience, but understandable.
So, back to the Nucleus configuration.  The "normal" way of doing fancyurls (using FilesMatch and ForceType magic) doesn't work on GoDaddy, since the PHP execution mechanism is long gone by the time Apache reaches the .htaccess file and ForceType.  The alternative way listed in the documentation that uses mod_rewrite seems inadequate:  it doesn't use the "Fancy URLs" mechanism in Nucleus, and the URLs really do feel less fancy as a result.  Now that mod_rewrite seems to work correctly, we can use it to implement the extra/fancyurls files in a better way.  I configured .htaccess as follows:
Options FollowSymLinks
RewriteEngine On
RewriteRule ^member/(.*) index.php?arr=member/$1
RewriteRule ^item/(.*) index.php?arr=item/$1
RewriteRule ^category/(.*) index.php?arr=category/$1
RewriteRule ^blog/(.*) index.php?arr=blog/$1
RewriteRule ^archive/(.*) index.php?arr=archive/$1
RewriteRule ^archives/(.*) index.php?arr=archives/$1
...and then changed index.php to sort this out in a big switch statement before  handing over to selector().]]></description>
		<wfw:commentRss>http://gidden.net/tom/2006/05/26/4/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
	</channel>
</rss>

