Wednesday, November 11, 2009

Finding My Way On FreeBSD

I recently landed a client who's hosting environment wasn't the usual Linux or Windows - it was FreeBSD. Even though FreeBSD and Linux share a common philosophy, I still found myself quite disoriented after logging in. Here are a few items I managed to figure out in a hurry:

  • I wanted to install GNU screen, and figured there had to be an equivalent to yum on FreeBSD. And of course there is, it's pkg_add. I ran the command:
    sudo pkg_add -r screen 
    and a few seconds later, screen was installed.
  • The find command kept error'ing out on me when I ran it. Turns out the syntax is just a bit pickier on FreeBSD than Linux. For example, I was entering:
    find -name 'foo'
    but should have been entering:
    find . -name 'foo'
    The starting path, which is optional on Linux is required on FreeBSD. This cheatsheet proved useful for untangling this one.
  • I went to restart apache and realized the /etc/ tree was significantly different on FreeBSD than on Linux. Apparently the preferred way to restart apache is:
    /usr/local/sbin/apachectl stop
    /usr/local/sbin/apachectl start
    I found this howto to be just what I needed to resolve this issue. In fact, looks like it might be a handy resource going forward.
  • Bonus: While not FreeBSD specific, I did need to figure out how to run PHP4 and PHP5 on the same box at the same time. Unfortunately, simply loading both modules doesn't work. I ended up keeping PHP4 as a module, and kicking off PHP5 via CGI. The solution is outlined here. I'm not in love with performance ramifications of running PHP5 out of cgi-bin, but all things considered, it's a clean solution.

It's amazing how the littlest things can make working in a new server environment feel like your only limping along. Luckily, the leap from Linux to FreeBSD is painless enough that I was jogging in no time.


  1. BSD was actually my first introduction to the Unix world. BSD was the base/backbone of the NeXTStep/OpenStep OS and now MacOSX. Really there is not much functionally different between the BSD Linux and Unix, just a bit of syntax and different installers, oh and having to 'port' everything meaning that almost anything that will run on Linux will work on BSD, you just have to recompile, and if you are lucky, some one will have already made the 'port' files for you.

    I wonder if BSD still holds the record for uptime? or has Linux finally over taken it.

  2. Anonymous12:57 PM

    thanks for sharing this site. various kinds of ebooks are available in this site