/
lighttpd.rb
103 lines (88 loc) 路 3.81 KB
/
lighttpd.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class Lighttpd < Formula
desc "Small memory footprint, flexible web-server"
homepage "https://www.lighttpd.net/"
url "https://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.76.tar.xz"
sha256 "8cbf4296e373cfd0cedfe9d978760b5b05c58fdc4048b4e2bcaf0a61ac8f5011"
license "BSD-3-Clause"
livecheck do
url :homepage
regex(/href=.*?lighttpd[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 arm64_sonoma: "091059b0ac1e2356912caf2fe85f5bb0d88ebde56c43579d28c9a68b5eac1075"
sha256 arm64_ventura: "00fb719b4328a1b7593452f8f6bae234a595ca089492f192bc309bdab055502f"
sha256 arm64_monterey: "aa6d7a5fe4662bdbbae1389091aec850c99d47f851dca621a55f9fcf7e5e7844"
sha256 sonoma: "f5604bd4748f47f72e87a7e1192efc40748e1f1d7d271eb555e1bd6444776c75"
sha256 ventura: "685d709d0d522aace4a102e2b28c3c04f2e6a6079de349d6148f999796571a8e"
sha256 monterey: "596921b5fcabab2c21e6b75b54589016755e990cd86728810839b233cb4a830e"
sha256 x86_64_linux: "8aa1c17b796dfc07c3e4d7543abc43af33469b5236aada5531baf3f98f8a66e2"
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "openldap"
depends_on "openssl@3"
depends_on "pcre2"
uses_from_macos "libxcrypt"
# default max. file descriptors; this option will be ignored if the server is not started as root
MAX_FDS = 512
def install
args = %W[
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--sbindir=#{bin}
--with-bzip2
--with-ldap
--with-openssl
--without-pcre
--with-pcre2
--with-zlib
]
# autogen must be run, otherwise prebuilt configure may complain
# about a version mismatch between included automake and Homebrew's
system "./autogen.sh"
system "./configure", *args
system "make", "install"
unless File.exist? etc/"lighttpd"
(etc/"lighttpd").install "doc/config/lighttpd.conf", "doc/config/modules.conf"
(etc/"lighttpd/conf.d/").install Dir["doc/config/conf.d/*.conf"]
inreplace etc + "lighttpd/lighttpd.conf" do |s|
s.sub!(/^var\.log_root\s*=\s*".+"$/, "var.log_root = \"#{var}/log/lighttpd\"")
s.sub!(/^var\.server_root\s*=\s*".+"$/, "var.server_root = \"#{var}/www\"")
s.sub!(/^var\.state_dir\s*=\s*".+"$/, "var.state_dir = \"#{var}/lighttpd\"")
s.sub!(/^var\.home_dir\s*=\s*".+"$/, "var.home_dir = \"#{var}/lighttpd\"")
s.sub!(/^var\.conf_dir\s*=\s*".+"$/, "var.conf_dir = \"#{etc}/lighttpd\"")
s.sub!(/^server\.port\s*=\s*80$/, "server.port = 8080")
s.sub!(%r{^server\.document-root\s*=\s*server_root \+ "/htdocs"$}, "server.document-root = server_root")
s.sub!(/^server\.username\s*=\s*".+"$/, 'server.username = "_www"')
s.sub!(/^server\.groupname\s*=\s*".+"$/, 'server.groupname = "_www"')
s.sub!(/^#server\.network-backend\s*=\s*"sendfile"$/, 'server.network-backend = "writev"')
# "max-connections == max-fds/2",
# https://redmine.lighttpd.net/projects/1/wiki/Server_max-connectionsDetails
s.sub!(/^#server\.max-connections = .+$/, "server.max-connections = " + (MAX_FDS / 2).to_s)
end
end
(var/"log/lighttpd").mkpath
(var/"www/htdocs").mkpath
(var/"lighttpd").mkpath
end
def caveats
<<~EOS
Docroot is: #{var}/www
The default port has been set in #{etc}/lighttpd/lighttpd.conf to 8080 so that
lighttpd can run without sudo.
EOS
end
service do
run [opt_bin/"lighttpd", "-D", "-f", etc/"lighttpd/lighttpd.conf"]
keep_alive false
error_log_path var/"log/lighttpd/output.log"
log_path var/"log/lighttpd/output.log"
working_dir HOMEBREW_PREFIX
end
test do
system "#{bin}/lighttpd", "-t", "-f", etc/"lighttpd/lighttpd.conf"
end
end