I am currently working on a Django project that will run on FreeBSD when deployed. I had never worked with this distro before, so it took a bit of getting used to, and I ended up reading man pages and Googling mailing list archives until the wee hours of the morning. One issue that really caught me by surprise was recompiling Apache 2.2 with the proxy modules, so I thought I would jot down my notes here.
The solution is pretty simple, but first I have to give some context. If you are not familiar with FreeBSD, it uses a ports & packages analogy for installing software. Their library is pretty good and contained pretty much everything I would need, from mod_python to psycopg2 (I couldn’t use psycopg2 due to a screw-up in their release management and had to settle back to psycopg, but that’s another issue). To compile a port, you basically do this:
cd /usr/ports/www/apache22
make install clean
And that’s it. If the port isn’t there, it’s downloaded and its dependencies are downloaded and compiled as well. Pretty good so far.
My problems started when I noticed that Apache 2.2 was not compiled with the proxy modules. So I searched the FreeBSD ports collection, only to realize that there is no port for the proxy modules. Confused, I started Googling for solutions. After a while, I came across a mailing list post that suggested I should recompile Apache in order to get some modules. The suggested format was this:
cd /usr/ports/www/apache22
make clean
make WITH_PROXY_MODULES=yes
make deinstall
make reinstall
Because FreeBSD ports don’t use the familiar ./configure model, they have these special variables called “knobs” that you can pass to make. I don’t know why they decided to stray from the standard, it would have been a lot simpler to not reinvent the wheel.
Anyway, as you can imagine, my problems did not stop there. I recompiled Apache maybe ten times, while trying to pass this WITH_PROXY_MODULES knob, and it didn’t work once. make happily recompiled Apache for me, ignoring my settings. I saw several blog posts and mailing list answers with different suggestions, and all of them were wrong - until I came across one that talked about how to get a list of compile settings from make:
cd /usr/ports/www/apache22
make show-options
make show-categories
make show-modules
Once again, a non-standard way of accessing the help text screwed me over. I had tried passing —help to make, and it ignored the flag, starting to compile immediately. Simply horrible design.
Finally, after reading the instructions from these flags, I learned that in order to have WITH_PROXY_MODULES work, you have to pass another knob, WITHOUT_APACHE_OPTIONS. So I recompiled once again:
cd /usr/ports/www/apache22
make clean
make WITHOUT_APACHE_OPTIONS=yes WITH_PROXY_MODULES=yes
make deinstall
make reinstall
To my absolute joy, this worked. I still had to include LoadModule lines in my httpd.conf for mod_proxy and its sub-modules, so don’t forget about that.
Final verdict: FreeBSD is not that bad. I don’t know why the default shell is tcsh, or the ports system is straying from well-established standards so much, but it’s still light years ahead of other distros like RedHat/Fedora/CentOS, which I deem downright unusable. However, for a Debian/Ubuntu user, there really is no point in using FreeBSD unless you have no other choice.
Well, it might seem a bit confusing at first, but there’s actually a configuration system in the ports system…
For the ports that have it enabled (like apache22 does), the canonical way to install with custom configuration is:
# make config
# make install clean
Yeah, what he (Eivind) said.
Remember, Linux is loosely based on the SysV world of unix (init.d and such) and is a Unix clone, while FreeBSD is, well, a free version of BSD Unix.
SysV and BSD have their own way of doing things.
Every Linux has a slightly different way of doing things.
The one nice thing about FreeBSD is that it is from stem to stern a complete OS. One FreeBSD will look like another.
I’m going the other way - having been a long time FreeBSD sysadmin now I have some Debian stuff to manage. I miss FreeBSD ports. I like having third party packages to under /usr/local/etc, /usr/local/sbin and such. I dislike seeing third party packages show up in /etc/somepackage and /usr/sbin/someexecutable and such.
Maybe it’s my heritage; I used to work for a big iron Unix vendor and I like order.
Word of advice: get to learn portmaster and portsnap.
And: “use the source, Luke:”
Thanks for the advice & clarifications guys, it’s truly appreciated. I am still trying to get my head around some things in FreeBSD, but as I mentioned in the post, relative to my experience with RedHat, FreeBSD has been quite painless.
© Copyright 2001-2010 Taylan Pince. All rights reserved.
FreeBSD is not a distro. It’s a self contained unix based operating system.