2017-09-29 14:12:03 +00:00
|
|
|
class Httpd < Formula
|
|
|
|
desc "Apache HTTP server"
|
|
|
|
homepage "https://httpd.apache.org/"
|
2017-10-27 10:14:30 +00:00
|
|
|
url "https://www.apache.org/dyn/closer.cgi?path=httpd/httpd-2.4.29.tar.bz2"
|
|
|
|
sha256 "777753a5a25568a2a27428b2214980564bc1c38c1abf9ccc7630b639991f7f00"
|
2017-12-28 00:43:02 +00:00
|
|
|
revision 1
|
2017-09-29 14:12:03 +00:00
|
|
|
|
|
|
|
bottle do
|
2017-12-28 00:57:15 +00:00
|
|
|
sha256 "1e2a9985867f72db8af9f85753bd1fe700a1780a03ad60b88b2df55d75dc78d1" => :high_sierra
|
|
|
|
sha256 "72e76b6c6fec4f7726884b112cb87fa7ef24ec0ddb945e1b78c35d013b87253b" => :sierra
|
|
|
|
sha256 "6776215fd1c0e937a7464dcd9d3143cc22d917a5381dc28ea6ff6242eba3b2a6" => :el_capitan
|
2017-09-29 14:12:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
depends_on "apr"
|
|
|
|
depends_on "apr-util"
|
|
|
|
depends_on "nghttp2"
|
|
|
|
depends_on "openssl"
|
|
|
|
depends_on "pcre"
|
|
|
|
|
|
|
|
def install
|
2017-10-03 07:59:17 +00:00
|
|
|
# fixup prefix references in favour of opt_prefix references
|
|
|
|
inreplace "Makefile.in",
|
|
|
|
'#@@ServerRoot@@#$(prefix)#', '#@@ServerRoot@@'"##{opt_prefix}#"
|
|
|
|
inreplace "docs/conf/extra/httpd-autoindex.conf.in",
|
|
|
|
"@exp_iconsdir@", "#{opt_pkgshare}/icons"
|
|
|
|
inreplace "docs/conf/extra/httpd-multilang-errordoc.conf.in",
|
|
|
|
"@exp_errordir@", "#{opt_pkgshare}/error"
|
|
|
|
|
2017-10-03 09:21:04 +00:00
|
|
|
# fix default user/group when running as root
|
|
|
|
inreplace "docs/conf/httpd.conf.in", /(User|Group) daemon/, "\\1 _www"
|
|
|
|
|
2017-09-29 14:12:03 +00:00
|
|
|
# use Slackware-FHS layout as it's closest to what we want.
|
|
|
|
# these values cannot be passed directly to configure, unfortunately.
|
|
|
|
inreplace "config.layout" do |s|
|
2017-10-03 07:59:17 +00:00
|
|
|
s.gsub! "${datadir}/htdocs", "${datadir}"
|
|
|
|
s.gsub! "${htdocsdir}/manual", "#{pkgshare}/manual"
|
2017-09-29 14:12:03 +00:00
|
|
|
s.gsub! "${datadir}/error", "#{pkgshare}/error"
|
|
|
|
s.gsub! "${datadir}/icons", "#{pkgshare}/icons"
|
|
|
|
end
|
|
|
|
|
|
|
|
system "./configure", "--enable-layout=Slackware-FHS",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--sbindir=#{bin}",
|
|
|
|
"--mandir=#{man}",
|
|
|
|
"--sysconfdir=#{etc}/httpd",
|
|
|
|
"--datadir=#{var}/www",
|
|
|
|
"--localstatedir=#{var}",
|
2017-09-29 15:21:30 +00:00
|
|
|
"--enable-mpms-shared=all",
|
2017-09-29 14:12:03 +00:00
|
|
|
"--enable-mods-shared=all",
|
2017-12-28 00:43:02 +00:00
|
|
|
"--enable-cgi",
|
2017-09-29 14:12:03 +00:00
|
|
|
"--enable-pie",
|
2017-10-03 09:21:04 +00:00
|
|
|
"--enable-suexec",
|
|
|
|
"--with-suexec-bin=#{opt_bin}/suexec",
|
|
|
|
"--with-suexec-caller=_www",
|
2017-09-29 14:12:03 +00:00
|
|
|
"--with-port=8080",
|
|
|
|
"--with-sslport=8443",
|
|
|
|
"--with-apr=#{Formula["apr"].opt_prefix}",
|
|
|
|
"--with-apr-util=#{Formula["apr-util"].opt_prefix}",
|
2017-10-09 20:00:57 +00:00
|
|
|
"--with-mpm=prefork",
|
2017-09-29 14:12:03 +00:00
|
|
|
"--with-nghttp2=#{Formula["nghttp2"].opt_prefix}",
|
|
|
|
"--with-ssl=#{Formula["openssl"].opt_prefix}",
|
|
|
|
"--with-pcre=#{Formula["pcre"].opt_prefix}"
|
|
|
|
system "make", "install"
|
|
|
|
|
2017-10-03 09:21:04 +00:00
|
|
|
# suexec does not install without root
|
|
|
|
bin.install "support/suexec"
|
|
|
|
|
2017-09-29 14:12:03 +00:00
|
|
|
# remove non-executable files in bin dir (for brew audit)
|
|
|
|
rm bin/"envvars"
|
|
|
|
rm bin/"envvars-std"
|
|
|
|
|
|
|
|
# avoid using Cellar paths
|
|
|
|
inreplace %W[
|
|
|
|
#{include}/httpd/ap_config_layout.h
|
2017-10-03 07:59:17 +00:00
|
|
|
#{lib}/httpd/build/config_vars.mk
|
2017-09-29 14:12:03 +00:00
|
|
|
] do |s|
|
|
|
|
s.gsub! "#{lib}/httpd/modules", "#{HOMEBREW_PREFIX}/lib/httpd/modules"
|
2017-10-03 07:59:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
inreplace %W[
|
|
|
|
#{bin}/apachectl
|
|
|
|
#{bin}/apxs
|
|
|
|
#{include}/httpd/ap_config_auto.h
|
|
|
|
#{include}/httpd/ap_config_layout.h
|
|
|
|
#{lib}/httpd/build/config_vars.mk
|
|
|
|
#{lib}/httpd/build/config.nice
|
|
|
|
] do |s|
|
2017-09-29 14:12:03 +00:00
|
|
|
s.gsub! prefix, opt_prefix
|
|
|
|
end
|
2017-10-03 07:59:17 +00:00
|
|
|
|
2017-09-29 14:12:03 +00:00
|
|
|
inreplace "#{lib}/httpd/build/config_vars.mk" do |s|
|
|
|
|
pcre = Formula["pcre"]
|
|
|
|
s.gsub! pcre.prefix.realpath, pcre.opt_prefix
|
|
|
|
s.gsub! "${prefix}/lib/httpd/modules",
|
|
|
|
"#{HOMEBREW_PREFIX}/lib/httpd/modules"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 09:21:04 +00:00
|
|
|
def caveats
|
2017-10-18 10:10:48 +00:00
|
|
|
<<~EOS
|
2017-10-03 09:21:04 +00:00
|
|
|
DocumentRoot is #{var}/www.
|
|
|
|
|
|
|
|
The default ports have been set in #{etc}/httpd/httpd.conf to 8080 and in
|
|
|
|
#{etc}/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2017-09-29 14:12:03 +00:00
|
|
|
def post_install
|
|
|
|
(var/"cache/httpd").mkpath
|
|
|
|
(var/"www").mkpath
|
|
|
|
end
|
|
|
|
|
|
|
|
plist_options :manual => "apachectl start"
|
|
|
|
|
2017-10-18 10:10:48 +00:00
|
|
|
def plist; <<~EOS
|
2017-09-29 14:12:03 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//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_bin}/httpd</string>
|
|
|
|
<string>-D</string>
|
|
|
|
<string>FOREGROUND</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
begin
|
|
|
|
expected_output = "Hello world!"
|
|
|
|
(testpath/"index.html").write expected_output
|
2017-10-18 10:10:48 +00:00
|
|
|
(testpath/"httpd.conf").write <<~EOS
|
2017-09-29 14:12:03 +00:00
|
|
|
Listen 8080
|
|
|
|
DocumentRoot "#{testpath}"
|
|
|
|
ErrorLog "#{testpath}/httpd-error.log"
|
|
|
|
LoadModule authz_core_module #{lib}/httpd/modules/mod_authz_core.so
|
|
|
|
LoadModule unixd_module #{lib}/httpd/modules/mod_unixd.so
|
|
|
|
LoadModule dir_module #{lib}/httpd/modules/mod_dir.so
|
2017-10-09 20:00:57 +00:00
|
|
|
LoadModule mpm_prefork_module #{lib}/httpd/modules/mod_mpm_prefork.so
|
2017-09-29 14:12:03 +00:00
|
|
|
EOS
|
|
|
|
|
|
|
|
pid = fork do
|
2017-10-09 20:00:57 +00:00
|
|
|
exec bin/"httpd", "-X", "-f", "#{testpath}/httpd.conf"
|
2017-09-29 14:12:03 +00:00
|
|
|
end
|
|
|
|
sleep 3
|
|
|
|
|
2017-10-03 09:21:04 +00:00
|
|
|
assert_match expected_output, shell_output("curl -s 127.0.0.1:8080")
|
2017-09-29 14:12:03 +00:00
|
|
|
ensure
|
|
|
|
Process.kill("TERM", pid)
|
|
|
|
Process.wait(pid)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|