diff --git a/Aliases/apache-httpd b/Aliases/apache-httpd new file mode 120000 index 0000000000..65420f86cb --- /dev/null +++ b/Aliases/apache-httpd @@ -0,0 +1 @@ +../Formula/httpd.rb \ No newline at end of file diff --git a/Aliases/apache2 b/Aliases/apache2 new file mode 120000 index 0000000000..65420f86cb --- /dev/null +++ b/Aliases/apache2 @@ -0,0 +1 @@ +../Formula/httpd.rb \ No newline at end of file diff --git a/Formula/httpd.rb b/Formula/httpd.rb new file mode 100644 index 0000000000..8f7ae7aeff --- /dev/null +++ b/Formula/httpd.rb @@ -0,0 +1,119 @@ +class Httpd < Formula + desc "Apache HTTP server" + homepage "https://httpd.apache.org/" + url "https://www.apache.org/dyn/closer.cgi?path=httpd/httpd-2.4.27.tar.bz2" + sha256 "71fcc128238a690515bd8174d5330a5309161ef314a326ae45c7c15ed139c13a" + revision 1 + + bottle do + sha256 "d35e67ae745053cda23273a520ead6bde506ec8082057edcd3185c9e36eae483" => :sierra + sha256 "4ea7056d6c08f9cf49507869aa8c78e3522c601d87b3347d31561ba05b33d41c" => :el_capitan + sha256 "e6ae5c4d38b40bcf3d85877ac117a1ea048de774edec3c2b0ff714bc01a6d40a" => :yosemite + end + + depends_on "apr" + depends_on "apr-util" + depends_on "nghttp2" + depends_on "openssl" + depends_on "pcre" + + def install + # 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| + s.gsub! "${datadir}/cgi-bin", "#{pkgshare}/cgi-bin" + s.gsub! "${datadir}/error", "#{pkgshare}/error" + s.gsub! "${datadir}/htdocs", "#{pkgshare}/htdocs" + 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}", + "--enable-mods-shared=all", + "--enable-pie", + "--with-port=8080", + "--with-sslport=8443", + "--with-apr=#{Formula["apr"].opt_prefix}", + "--with-apr-util=#{Formula["apr-util"].opt_prefix}", + "--with-nghttp2=#{Formula["nghttp2"].opt_prefix}", + "--with-ssl=#{Formula["openssl"].opt_prefix}", + "--with-pcre=#{Formula["pcre"].opt_prefix}" + system "make", "install" + + # remove non-executable files in bin dir (for brew audit) + rm bin/"envvars" + rm bin/"envvars-std" + + # avoid using Cellar paths + inreplace %W[ + #{lib}/httpd/build/config_vars.mk + #{include}/httpd/ap_config_layout.h + ] do |s| + s.gsub! "#{lib}/httpd/modules", "#{HOMEBREW_PREFIX}/lib/httpd/modules" + s.gsub! prefix, opt_prefix + end + 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 + + def post_install + (var/"cache/httpd").mkpath + (var/"www").mkpath + end + + plist_options :manual => "apachectl start" + + def plist; <<-EOS.undent + + + + + Label + #{plist_name} + ProgramArguments + + #{opt_bin}/httpd + -D + FOREGROUND + + RunAtLoad + + + + EOS + end + + test do + begin + expected_output = "Hello world!" + (testpath/"index.html").write expected_output + (testpath/"httpd.conf").write <<-EOS.undent + 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 + EOS + + pid = fork do + exec bin/"httpd", "-DFOREGROUND", "-f", "#{testpath}/httpd.conf" + end + sleep 3 + + assert_match expected_output, shell_output("curl 127.0.0.1:8080") + ensure + Process.kill("TERM", pid) + Process.wait(pid) + end + end +end diff --git a/formula_renames.json b/formula_renames.json index 804fb56052..38a6cb8296 100644 --- a/formula_renames.json +++ b/formula_renames.json @@ -77,6 +77,7 @@ "gtef": "tepl", "hamsterdb": "upscaledb", "heroku-toolbelt": "heroku", + "httpd24": "httpd", "influxdb08": "influxdb@0.8", "isl011": "isl@0.11", "isl012": "isl@0.12",