在osx上安装 lighttpd是一个很有意思的过程。主要还是因为MacPorts不止是编译了lighttpd,还加上了一些好用的脚本。 :)
安装还是很简单的:
sudo port install lighttpd |
安装好后,需要配置lighttpd.conf:
sudo cp /opt/local/etc/lighttpd/lighttpd.conf.default /opt/local/etc/lighttpd/lighttpd.conf |
修改其中的一些配置,这个可以参考lighttpd自己的一些说明。一定会修改的是:server.document-root、server.errorlog、accesslog.filename。
配置好了,来试试lighttpd是不是可以启动:
sudo /opt/local/sbin/lighttpd -f /opt/local/etc/lighttpd/lighttpd.conf |
接下来是MacPorts给我们带来的了,首先它准备好了一个适用于osx的启动说明文件/Library/LaunchDaemons/org.macports.lighttpd.plist,内容如下:
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd > <plist version='1.0'> <dict> <key>Label</key><string>org.macports.lighttpd</string> <key>ProgramArguments</key> <array> <string>/opt/local/bin/daemondo</string> <string>--label=lighttpd</string> <string>--start-cmd</string> <string>/opt/local/etc/LaunchDaemons/org.macports.lighttpd/lighttpd.wrapper</string> <string>start</string> <string>;</string> <string>--stop-cmd</string> <string>/opt/local/etc/LaunchDaemons/org.macports.lighttpd/lighttpd.wrapper</string> <string>stop</string> <string>;</string> <string>--restart-cmd</string> <string>/opt/local/etc/LaunchDaemons/org.macports.lighttpd/lighttpd.wrapper</string> <string>restart</string> <string>;</string> <string>--pid=none</string> </array> <key>Debug</key><false/> <key>Disabled</key><false/> <key>OnDemand</key><false/> <key>RunAtLoad</key><false/> </dict> </plist> |
这个xml文件还是比较容易看的。不过我们不用去修改它。我们可以通过一个简单的命令,来将它变为系统的启动Daemon:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.lighttpd.plist |