104 lines
3.8 KiB
Ruby
104 lines
3.8 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.68.tar.xz"
|
|
sha256 "e56f37ae52b63e1ada4d76ce78005affb6e56eea2f6bdb0ce17d6d36e9583384"
|
|
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_ventura: "1a30aefdaab4819bee28c3f63da0867f0031f825cd4dac522744b4d19162bc29"
|
|
sha256 arm64_monterey: "9dcbe27271a0cfb493dede9c97f5eb262c14e7f0e8fbb7aacced962040771f45"
|
|
sha256 arm64_big_sur: "b50b76039099704c744783debd8be8e392305e321ced2943063e1af7e9173002"
|
|
sha256 ventura: "3b12c865b261aaee2a999dfa73256b3cf1b55c3f2068ac41f60739d815657187"
|
|
sha256 monterey: "57ed3baffc69083d2d203e250f0b9320f90014a33901b930724594ae465bd18c"
|
|
sha256 big_sur: "d5d5f82673b4f4be6cde5a1f5b0af436c0eb5464288a8c95c59b9b18e31ea40a"
|
|
sha256 x86_64_linux: "7b0bc2fcaf8480de212268387ecd77162d89760a817c17d130c0d55a417c9445"
|
|
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"
|
|
|
|
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
|