FreeBSD10.1 with lighttpd, php5 and mariadb

Last edited

FreeBSD 10.1

FreeBSD 10.1 is a great platform for your servers. It is remarkably fast and easy to install and manage.

With the new binary packagemanagement system you don't have to wait ages for your ports are compiled.

Of course FreeBSD 10.1 is without systemd !

Install FreeBSD 10.1

FreeBSD 10.1 is very easy to install. Just download the iso, I used the file FreeBSD-10.1-RELEASE-amd64-disc1.iso. Booting from this iso you will enter the installer. When you choose the default options, you will find that it is very simple to do.

I did not install the ports, no need to compile a lot of add ons, the number of binary packages that can be installed with pkg is big enough.

FreeBSD is famous for its wonderfull man-pages. Use them. Don't forget to read man afterboot after the first reboot after completing the installation. Also the FreeBSD handbook is a priceless source of information.

Update your system first

After installing you should bring your system up to date with:

freebsd-update fetch
freebsd-update install

This is no Microsoft windows, so you don't have to be afraid or hate updates.

Install mariadb

We choose to install MariaDB as an alternative for MySQL. Oracle governs MySQL and is killing it softly by slowing down the development of MySQL.

MariaDB is a drop-in replacement for MySQL. This means you can install MariaDB in stead of MySQL and all your programs will work unchanged, but on top of a better database engine :)

pkg install mariadb100-client-10.0.17 mariadb100-server-10.0.17
echo 'mysql_enable=YES' >> /etc/rc.conf
/usr/local/etc/rc.d/mysql-server start
cd /usr/local/etc

This last line is to set up the root password for mariadb, remove the mariadb test database et cetera.

Install lighttpd

pkg install -y lighttpd
echo 'lighttpd_enable=YES' >> /etc/rc.conf
mkdir -p /usr/local/www/data

Install PHP

pkg install php56 php56-mysql php56-json php56-session

Edit config-files


Edit this file, remove the single sharp-symbols (#) before the fastcgi-server block. Also, edit the lines with bin-path, change these into:

"bin-path" => "/usr/local/bin/php-cgi",

When you left the line with socket unchanged, you have to create the directory mentioned in this line:

mkdir -p /var/spool/lighttpd/sockets/
chown www:www /var/spool/lighttpd/sockets/


Edit this file, in the bottom you see the listening address, change the ip address into the ip address of your server.


In this file, remove the sharp (#) before:

 include "conf.d/fastcgi.conf"

Create php.ini

Copy either /usr/local/etc/php.ini-development or /usr/local/etc/php.ini-production to /usr/local/etc/php.ini.

Edit the php.ini file and remove the semi-colon (;) before:


Start lighttpd

/usr/local/etc/rc.d/lighttpd start

If everything went well, you now have a working webserver with PHP and MariaDB as a drop-in replacement for MySQL.

If all is well, you can add things like gd and other goodies you might want, and install your development tools like vim, git and perl modules.