homebrew-core/Formula/lighttpd.rb

108 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.65.tar.xz"
sha256 "bf0fa68a629fbc404023a912b377e70049331d6797bcbb4b3e8df4c3b42328be"
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: "db80d84616d0aa7545053954ac9aceb39f4a0292312fb3a5cf25832ec18885f7"
sha256 arm64_big_sur: "b487c5582c7e274d75b96c48d797f5412dc98e3fbd6fed983c1bb27f215cf3d3"
sha256 monterey: "4d51fcffebf54446404638950479601015a7eefe8b7eadba2daa57cc93a455db"
sha256 big_sur: "499d8f4b017808b04562733dbd9869baa86c7bcdea610d2d50279136f0599507"
sha256 catalina: "f8de4f961e02913745a27730bf6c0c0e28093eb29f72aa683b25649e03a06a8b"
sha256 x86_64_linux: "0f6b6e0b0914a10060a48b486cabdc3dffa514640e121caf76581dd5528cc57e"
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")
# 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