106 lines
4.0 KiB
Ruby
106 lines
4.0 KiB
Ruby
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.64.tar.xz"
|
|
sha256 "e1489d9fa7496fbf2e071c338b593b2300d38c23f1e5967e52c9ef482e1b0e26"
|
|
license "BSD-3-Clause"
|
|
|
|
livecheck do
|
|
url "https://www.lighttpd.net/download/"
|
|
regex(/href=.*?lighttpd[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "bcf37fd9c04f41481779f01bcc6a99b70ad92c3ce1a0b1e7420498d425fc4811"
|
|
sha256 arm64_big_sur: "75560ba16722115eb40465408ad2c6e98e4045c30f57e45d0f8814652c402fc6"
|
|
sha256 monterey: "e512bab9a55d348cdc6ed051c065c02cc7ba75f09c164b6d62069ae1db39ea3c"
|
|
sha256 big_sur: "1f8d5019d3a0106da00e13c4ae817bf52536d7a2722b195cd79c6f2d91b36c56"
|
|
sha256 catalina: "d1b54887a11604f8c36440248b50ff961f35c166b075d86c84b90e1708f9fd3d"
|
|
sha256 x86_64_linux: "aa4bf269c6d1e357f4c07236e9a9c4053bd67803029aba23bf2ddfbcb0e81b65"
|
|
end
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "openldap"
|
|
depends_on "openssl@1.1"
|
|
depends_on "pcre2"
|
|
|
|
# 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")
|
|
|
|
# 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"
|
|
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\.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
|