Getting Lighttpd 1.4 and PHP 5 to work on FreeBSD
on Wednesday 26th September, 2007 Gabe speculated thusly…Firstly let me just say that I had quite a few problem with Lighttp (aka Lighty), and some of them related to PHP. However, I now have Lighty, PHP, and MySQL playing nicely and… it’s fast! This was tested with: Lighty 1.4.18 and PHP 5.2.3_1 on FreeBSD 6.2.For the installation of these programs it is almost a must to install from the latest ports snapshot. Installing from ports allows you to compile with certain options, for example CGI support, and it also ensures you have the very latest release. This is important since even right now the latest PHP5 in ports (5.2.3_1) has security problems, and so too does Lighttpd 1.4.18. Therefore it is vital that these can be updated at the soonest possible time. Personally, I don’t mind a few security niggles, and while Lighty retains a fairly small percentage of the server market it shouldn’t be subjected to bad attacks.
For me, I wanted to use Lighty and PHP with MySQL. The easiest way to install PHP and PHP MySQL support is to just install the php5-extensions. So change to their directory:
cd /usr/ports/lang/php5-extensionsmake config
Now choose all the different extensions you want, which would normally include MySQL. When asked about PHP options make sure you enable FastCGI.
- For me I chose to install:
- CLI
- CGI
- Suhosin
- IPV6
- FastCGI
- Path Info
If you don’t want all the fluff you can just change directory to
cd /usr/ports/lang/php5make config
Choose the options here. In either case after running:
make config
you need to run:
make install clean
Tags: guide, HowTo, php, web service