1. 安装
# cd /build/ports/www/lighttpd
# make install clen
此时会出现一个模块选择框,根据自己的需要选择。
2. 设置配置文件
将目录”/usr/local/etc/”下的”lighttpd.conf.sample”复制为”lighttpd.conf”,给予”lighttpd.conf”文件写权限后使用编辑器打开它,进行如下设置:
开启模块
在”server.modules”段中打开以下模块:
mod_fastcgi
设置页面地址
设置”server.document-root”,修改默认的站点地址。
设置PHP支持
将”fastcgi.server”段设置如下:
fastcgi.server = (
".php" => (
"localhost" => (
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/local/bin/php-cgi"
)
)
)
2. 创建相关文件及目录
创建日志文件并设置权限:
touch /var/log/lighttpd.error.log
touch /var/log/lighttpd.access.log
chown www:www /var/log/lighttpd.*
创建PID文件存放目录并设置权限:
mkdir /var/run/lighttpd
chown www:www /var/run/lighttpd
3. 启动服务
使用以下命令临时启动服务:
/usr/local/etc/rc.d/lighttpd onestart
如果要在系统启动时自动启动服务,可以在”/etc/rc.conf”中添加以下语句:
lighttpd_enable="YES"