Tuesday, February 26, 2008

Basic apache configuration in FreeBSD

So I decided to try out apache in FreeBSD...
pkg_add -rv apache
vi /usr/local/etc/apache/httpd.conf
Added the lines:
ServerName www
BindAddress *
Supposing my hostname is dvorak, I need to edit
vi /etc/hosts
and add the line:
127.0.0.1 dvorak
And now
apachectl start
The DocumentRoot is /usr/local/www/data in this default configuration.

Great. Now it "works" but being given the default config, right now I can't enter non-Latin characters in files/filenames. I'd basically need UTF-8 exported as charset. The solution is to make use of ~/.login_conf.

For a minimalistic ~/.login_conf, I need to do:
echo "me:\" >> ~/.login_conf
echo ":charset=UTF-8:\" >> ~/.login_conf
echo ":lang= en_US.UTF-8" >> ~/.login_conf
Wheee now I can enter stuff such as "şţăîâабкдеф" in the terminal!

More on setting locales (via ~/.login_conf) in the FreeBSD handbook.

Next on, I need to make apache know of UTF-8:
echo "AddDefaultCharset utf-8" >> /usr/local/etc/apache/httpd.conf
apachectl restart
Voilà!

Just one more thing: in order to have apache started automatically at each boot, I need an entry in /etc/rc.conf:
echo 'apache_enable="YES"' >> /etc/rc.conf

1 comment: