diff options
| author | Linas Valiukas | 2013-05-16 12:34:30 +0300 |
|---|---|---|
| committer | Mike McQuaid | 2013-09-12 17:53:23 +0100 |
| commit | df7d819de065bd3e7030c57cad0a2cdad9d6452e (patch) | |
| tree | 36a77413e18dbe2150eefc53b48fd1fbd79b46dd /Library/Formula | |
| parent | dfc5b737c0513f542771113d89d0213f0696f3f4 (diff) | |
| download | homebrew-df7d819de065bd3e7030c57cad0a2cdad9d6452e.tar.bz2 | |
lighttpd: copy config, use port 8080, add .plist.
* Copies the sample .conf files to etc/ modifying them to point to correct paths in /usr/local
* Changes default port to 8080 so that lighttpd can be started from unprivileged user
* Creates a startup .plist file for launchd.
Closes #19861.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/lighttpd.rb | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/Library/Formula/lighttpd.rb b/Library/Formula/lighttpd.rb index bb3ffb60c..c27bc8790 100644 --- a/Library/Formula/lighttpd.rb +++ b/Library/Formula/lighttpd.rb @@ -12,6 +12,14 @@ class Lighttpd < Formula depends_on 'lua' => :optional depends_on 'libev' => :optional + # default max. file descriptors; this option will be ignored if the server is not started as root + MAX_FDS = 512 + + def config_path; etc+"lighttpd/"; end + def log_path; var+"log/lighttpd/"; end + def www_path; var+"www/"; end + def run_path; var+"lighttpd/"; end + def install args = %W[ --disable-dependency-tracking @@ -28,5 +36,93 @@ class Lighttpd < Formula system "./configure", *args system "make install" + + unless File.exists? config_path + config_path.install Dir["doc/config/lighttpd.conf"] + config_path.install Dir["doc/config/modules.conf"] + (config_path/"conf.d/").install Dir["doc/config/conf.d/*.conf"] + inreplace config_path+"lighttpd.conf" do |s| + s.sub!(/^var\.log_root\s*=\s*".+"$/,"var.log_root = \"#{log_path}\"") + s.sub!(/^var\.server_root\s*=\s*".+"$/,"var.server_root = \"#{www_path}\"") + s.sub!(/^var\.state_dir\s*=\s*".+"$/,"var.state_dir = \"#{run_path}\"") + s.sub!(/^var\.home_dir\s*=\s*".+"$/,"var.home_dir = \"#{run_path}\"") + s.sub!(/^var\.conf_dir\s*=\s*".+"$/,"var.conf_dir = \"#{config_path}\"") + s.sub!(/^server\.port\s*=\s*80$/,'server.port = 8080') + + # get rid of "warning: please use server.use-ipv6 only for hostnames, not + # without server.bind / empty address; your config will break if the kernel + # default for IPV6_V6ONLY changes" warning + s.sub!(/^server.use-ipv6\s*=\s*"enable"$/,'server.use-ipv6 = "disable"') + + s.sub!(/^server\.username\s*=\s*".+"$/,'server.username = "_www"') + s.sub!(/^server\.groupname\s*=\s*".+"$/,'server.groupname = "_www"') + s.sub!(/^server\.event-handler\s*=\s*"linux-sysepoll"$/,'server.event-handler = "select"') + s.sub!(/^server\.network-backend\s*=\s*"linux-sendfile"$/,'server.network-backend = "writev"') + + # "max-connections == max-fds/2", + # http://redmine.lighttpd.net/projects/1/wiki/Server_max-connectionsDetails + s.sub!(/^server\.max-connections = .+$/,'server.max-connections = ' + (MAX_FDS / 2).to_s()) + end + end + end + + def post_install + log_path.mkpath + www_path.mkpath + (www_path/'htdocs').mkpath + run_path.mkpath + end + + def caveats; <<-EOS.undent + Docroot is: #{www_path}htdocs/ + + The default port has been set to 8080 so that lighttpd can run without sudo. + + If you want to host pages on your local machine to the wider network you + can change the port to 80 in: #{config_path}lighttpd.conf + + You will then need to run lighttpd as root: `sudo lighttpd -f #{config_path}lighttpd.conf`. + EOS + end + + plist_options :manual => "lighttpd" + + def plist; <<-EOS.undent + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + <plist version="1.0"> + <dict> + <key>Label</key> + <string>#{plist_name}</string> + <key>ProgramArguments</key> + <array> + <string>#{opt_prefix}/sbin/lighttpd</string> + <string>-D</string> + <string>-f</string> + <string>#{config_path}/lighttpd.conf</string> + </array> + <key>RunAtLoad</key> + <true/> + <key>KeepAlive</key> + <false/> + <key>WorkingDirectory</key> + <string>#{HOMEBREW_PREFIX}</string> + <key>StandardErrorPath</key> + <string>#{log_path}/output.log</string> + <key>StandardOutPath</key> + <string>#{log_path}/output.log</string> + <key>HardResourceLimits</key> + <dict> + <key>NumberOfFiles</key> + <integer>#{MAX_FDS}</integer> + </dict> + <key>SoftResourceLimits</key> + <dict> + <key>NumberOfFiles</key> + <integer>#{MAX_FDS}</integer> + </dict> + </dict> + </plist> + EOS end end |
