Friday, April 08, 2011

to MacPorts or not to MacPorts

Soooo...
About this whole Python thing.
It turns out that the more power you get the deeper you have to go.
In my particular case I had to go deep enough that the Snow Leopard 32 bit / 64 bit started to really matter.
The problem arise when I tried to install opencv for Python. Opencv has ffmpeg as a dependency. And ffmpeg is 64 bit only on Snow Leoaprd. And I was running Python in 32 bit mode (VERSIONER_PYTHON_PREFER_32_BIT=yes) because mod_wsgi was compiled agains my XAMPP Apache which in turn was 32 bit. So I had to cut the roots of the problem and ditch XAMPP altogether.
Good thing MacPorts is around. Kudos to those guys who maintain the whole thing. In around 2-3 hrs I was able to have a fully working LAMP stack and all my local dev projects including vhosts worked without major hassles. I even have the XAMPP around and I can fire it up anytime I need.
I had to uninstall all the ports first because while trying to hack opencv into submission I installed a bunch of universal variants of the ports and php5 refused to build with those around. It was a mess. But after uninstalling all ports and taking it step by step I had no troubles whatsoever. I imagine that this is not something everyone can do - ditching all the ports - but we all know that "square one" is a place you can always go back to ;-)
Some of the minor hassles that I had to work may way trough were:
  • manually creating and tweaking php.ini and my.cnf
  • manually editing httpd.conf to get perl and php to work
  • having to symlink /tmp/mysql.sock -> /opt/local/var/run/mysql5/mysqld.sock because CakePHP kept looking for mysql in the tmp folder. Not sure if it was Cake or PHP but now it works and MySQLWorkbench doesn't complain either
  • dumping all my databases from the XAMPP MySQL and importing them into the new MySQL with mysqldump --all-databases > backup_file.sql and mysql < backup_file.sql
  • figuring all the extra php extensions I needed using a rock solid older CentOS setup I did a while ago
Now I do realize that these are always on the todo list for any manual LAMP installation (even Windows) but it's just a heads up for those who didn't do this kind of job yet.

I recommend doing the MacPorts thing just for fun. You'll get a better idea of what's under the hood. And if you dont set anything to start at boot you don't risk breaking your current setup. When you see the added compile times you really understand that the whole LAMP thing is a huge effort and the fact that it seems so simple to use with great tools like XAMPP just adds up to it's coolness.
Now I have Apache2 in 64 bit mode and a brand new MySQL to go with it. Also PHP is at 5.3.6 and MacPorts has about all the PHP extensions you could need.
All I can say is that the same old lesson proved true again. In technology there's no solid ground. If you're not moving forward you're going backwards!

Now as you can imagine I've got no Python with mod_wsgi yet on the new setup :-)
Funny how the snake tricked me into going trough all this pain just to end up with less. But the foundation is solid and I have no doubt that all will fall nicely in place. More posts to follow on the topic as I expect to get further with this new approach.

Update: the MacPorts mod_wsgi works just fine. It is much simpler to install than the XAMPP bag of tricks. I got "Hello World" again. Next is Django but I'll really put that off for a later time.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home