forked from Ensembl/homebrew-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpd24.rb
146 lines (124 loc) · 4.72 KB
/
httpd24.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
class Httpd24 < Formula
desc "HTTP server"
homepage "https://httpd.apache.org/"
url "https://archive.apache.org/dist/httpd/httpd-2.4.23.tar.bz2"
sha256 "0c1694b2aad7765896faf92843452ee2555b9591ae10d4f19b245f2adfe85e58"
revision 2
bottle do
sha256 "3cf05ee1dae35c93aadc8c27d32fa88b998af6e7e387420c0b372e38d298b308" => :sierra
sha256 "41cd39db06ddbbc941e736c0700a9b218899239259eafb900f35f843b5a72cea" => :el_capitan
sha256 "bf5abcffd2fbfe3b592b21f581a7cff8e17ded70fd2d827dc0bb0fd33fd8af18" => :yosemite
end
conflicts_with "homebrew/apache/httpd22", :because => "different versions of the same software"
conflicts_with "homebrew/apache/httpd24", :because => "different versions of the same software"
skip_clean :la
option "with-mpm-worker", "Use the Worker Multi-Processing Module instead of Prefork"
option "with-mpm-event", "Use the Event Multi-Processing Module instead of Prefork"
option "with-privileged-ports", "Use the default ports 80 and 443 (which require root privileges), instead of 8080 and 8443"
option "with-ldap", "Include support for LDAP"
option "with-http2", "Build and enable the HTTP/2 shared Module"
depends_on "openssl"
depends_on "pcre"
depends_on "zlib"
if build.with? "ldap"
depends_on "apr-util" => "with-openldap"
else
depends_on "apr-util"
end
depends_on "nghttp2" if build.with? "http2"
if build.with?("mpm-worker") && build.with?("mpm-event")
raise "Cannot build with both worker and event MPMs, choose one"
end
def install
# point config files to opt_prefix instead of the version-specific prefix
inreplace "Makefile.in",
'#@@ServerRoot@@#$(prefix)#', '#@@ServerRoot@@'"##{opt_prefix}#"
# fix non-executable files in sbin dir (for brew audit)
inreplace "support/Makefile.in",
"$(DESTDIR)$(sbindir)/envvars", "$(DESTDIR)$(sysconfdir)/envvars"
inreplace "support/Makefile.in",
"envvars-std $(DESTDIR)$(sbindir);", "envvars-std $(DESTDIR)$(sysconfdir);"
inreplace "support/apachectl.in",
"@exp_sbindir@/envvars", "#{etc}/apache2/2.4/envvars"
# install custom layout
File.open("config.layout", "a") { |f| f.write(httpd_layout) }
args = %W[
--prefix=#{prefix}
--enable-layout=Homebrew
--enable-mods-shared=all
--enable-mpms-shared=all
--enable-unique-id
--enable-ssl
--enable-dav
--enable-cache
--enable-logio
--enable-deflate
--enable-cgi
--enable-cgid
--enable-suexec
--enable-rewrite
--with-apr=#{Formula["apr"].opt_prefix}/bin/apr-1-config
--with-apr-util=#{Formula["apr-util"].opt_prefix}/bin/apu-1-config
--with-pcre=#{Formula["pcre"].opt_prefix}
--with-ssl=#{Formula["openssl"].opt_prefix}
--with-z=#{Formula["zlib"].opt_prefix}
--libdir=#{HOMEBREW_PREFIX}/lib
]
if build.with? "mpm-worker"
args << "--with-mpm=worker"
elsif build.with? "mpm-event"
args << "--with-mpm=event"
else
args << "--with-mpm=prefork"
end
if build.with? "privileged-ports"
args << "--with-port=80" << "--with-sslport=443"
else
args << "--with-port=8080" << "--with-sslport=8443"
end
if build.with? "http2"
args << "--enable-http2" << "--with-nghttp2=#{Formula["nghttp2"].opt_prefix}"
end
if build.with? "ldap"
args << "--with-ldap" << "--enable-ldap" << "--enable-authnz-ldap"
end
(etc/"apache2/2.4").mkpath
system "./configure", *args
system "make"
system "make", "install"
(var/"apache2/log").mkpath
(var/"apache2/run").mkpath
touch("#{var}/log/apache2/access_log") unless File.exist?("#{var}/log/apache2/access_log")
touch("#{var}/log/apache2/error_log") unless File.exist?("#{var}/log/apache2/error_log")
end
def httpd_layout
<<-EOS
<Layout Homebrew>
prefix: #{prefix}
exec_prefix: ${prefix}
bindir: ${exec_prefix}/bin
sbindir: ${exec_prefix}/bin
libdir: ${exec_prefix}/lib
libexecdir: ${exec_prefix}/libexec
mandir: #{man}
infodir: #{info}
sysconfdir: #{etc}/apache2/2.4
datadir: #{var}/www
installbuilddir: ${prefix}/build
errordir: ${datadir}/error
iconsdir: ${datadir}/icons
htdocsdir: ${datadir}/htdocs
manualdir: ${datadir}/manual
cgidir: #{var}/apache2/cgi-bin
includedir: ${prefix}/include/httpd
localstatedir: #{var}/apache2
runtimedir: #{var}/run/apache2
logfiledir: #{var}/log/apache2
proxycachedir: ${localstatedir}/proxy
</Layout>
EOS
end
test do
system bin/"httpd", "-v"
end
end