FreeBSD
FreeBSD has the ports and lighttpd is in this tree for a long time now.
Код:
# cd /usr/ports/www/lighttpd
# make install clean
Код:
# cd /usr/ports/lang/php5/
# make install clean
Make sure you enable FastCGI support in the configuration dialog. If you don't get the configuration dialog, do "make config" first. The additional CONFIG_ARGS for the PHP5 installation force cgi-fcgi support in /usr/local/bin/php. The option '--with-pcre-regex' is needed to support several functions that use regular expressions like 'preg_match'.
php -v should give you something like this:
PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Dec 8 2007 05:47:06)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
PHP extensions are in /usr/ports/lang/php5-extensions/. If you need mySQL support, that is where you can find it, select only extensions that you actually need. During compiling when it asks you to install UTF8 support, I suggest you install it.
Код:
# cd /usr/ports/lang/php5-extensions
# make config
# make install clean
Now that everything is installed, enable Lighttpd in rc.conf and edit it's configuration:
Код:
# echo lighttpd_enable=\"YES\" >> /etc/rc.conf
# cd /usr/local/etc/
# cp lighttpd.conf.sample lighttpd.conf
# cp php.ini-recommended php.ini
You will probably need to create some directories and files, since the port neglects to do them for you (as of 2008 February 24):
Код:
# mkdir /var/log/lighttpd
# touch /var/log/lighttpd/lighttpd.error.log
# touch /var/log/lighttpd/lighttpd.access.log
Make your new directories and files accessible by the user and group "www" that Lighttpd operates as:
Код:
# chown www:www /var/log/lighttpd
# chown www:www /var/log/lighttpd/lighttpd.error.log
# chown www:www /var/log/lighttpd/lighttpd.access.log
Edit lighttpd.conf to use the new directories and files as follows:
Код:
* server.errorlog = "/var/log/lighttpd/lighttpd.error.log"
* accesslog.filename = "/var/log/lighttpd/lighttpd.access.log"
Edit lighttpd.conf docroot:
Код:
* server.document-root = "/usr/local/www/"
Test to make sure Lighttpd starts up properly:
Код:
# /usr/local/etc/rc.d/lighttpd start
If you need to, you may shutdown lighttpd this way:
Код:
# /usr/local/etc/rc.d/lighttpd stop
And then restart it with this:
Код:
# /usr/local/etc/rc.d/lighttpd restart
If you get an error that says "permission denied", check to make sure that the files and directories mentioned exist AND that user www has permission to operate on them. Also be sure that lighttpd.conf has been corrected from the non-working default version. If you get no errors, put an HTML file in /usr/local/www/ and try to load it up in your browser. If everything works, now enable PHP:
* In section "server.modules" uncomment the line "mod_fastcgi"
* uncomment the entire section "fastcgi.server"
* add the following lines under "socket" in the "fastcgi.server" section:
Код:
"bin-path" => "/usr/local/bin/php-cgi",
"broken-scriptfilename" => "enable"
Now make some more files and directories that are missing from the port (as of 2008 Feb 29):
Код:
# mkdir /var/run/lighttpd
# touch /var/run/lighttpd/php-fastcgi.socket
Make your new directories and files accessible by the user and group "www" that Lighttpd operates as:
Код:
# chown www:www /var/run/lighttpd
# chown www:www /var/run/lighttpd/php-fastcgi.socket