forked from rjocoleman/homebrew-apache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpd22.rb
166 lines (143 loc) · 5.04 KB
/
httpd22.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
require "formula"
class Httpd22 < Formula
homepage "https://httpd.apache.org/"
url "https://archive.apache.org/dist/httpd/httpd-2.2.29.tar.bz2"
sha1 "1d6a8fbc1391d358cc6fe430edc16222b97258d5"
conflicts_with "httpd24", :because => "different versions of the same software"
skip_clean :la
option "with-brewed-apr", "Use Homebrew's apr and apr-util instead of the bundled versions"
option "with-brewed-openssl", "Use Homebrew's SSL instead of the system version"
option "with-brewed-zlib", "Use Homebrew's zlib instead of the system version"
option "with-ldap", "Include support for LDAP"
option "with-privileged-ports", "Use the default ports 80 and 443 (which require root privileges), instead of 8080 and 8443"
if build.with? "brewed-apr"
depends_on "apr"
depends_on "apr-util"
end
depends_on "pcre" => :optional
depends_on "openssl" if build.with? "brewed-openssl"
depends_on "homebrew/dupes/zlib" if build.with? "brewed-zlib"
def install
# point config files to opt_prefix instead of the version-specific prefix
inreplace "Makefile.in",
'#@@ServerRoot@@#$(prefix)#', '#@@ServerRoot@@'"##{opt_prefix}#"
# install custom layout
File.open('config.layout', 'w') { |f| f.write(httpd_layout) };
args = %W[
--enable-layout=Homebrew
--enable-mods-shared=all
--with-mpm=prefork
--enable-unique-id
--enable-ssl
--enable-dav
--enable-cache
--enable-proxy
--enable-logio
--enable-deflate
--enable-cgi
--enable-cgid
--enable-suexec
--enable-rewrite
]
if build.with? "brewed-openssl"
openssl = Formula["openssl"].opt_prefix
args << "--with-ssl=#{openssl}"
else
args << "--with-ssl=/usr"
end
if build.with? "privileged-ports"
args << "--with-port=80"
args << "--with-sslport=443"
else
args << "--with-port=8080"
args << "--with-sslport=8443"
end
if build.with? "brewed-apr"
args << "--with-apr=#{Formula["apr"].opt_prefix}"
args << "--with-apr-util=#{Formula["apr-util"].opt_prefix}"
else
args << "--with-included-apr"
end
args << "--with-pcre=#{Formula['pcre'].opt_prefix}" if build.with? "pcre"
if build.with? "brewed-zlib"
args << "--with-z=#{Formula['zlib'].opt_prefix}"
else
args << "--with-z=#{MacOS.sdk_path}/usr"
end
if build.with? "ldap"
args << "--with-ldap"
args << "--enable-ldap"
args << "--enable-authnz-ldap"
end
system "./configure", *args
system "make"
system "make install"
(var/"apache2/log").mkpath
(var/"apache2/run").mkpath
touch("#{var}/log/apache2/access_log") unless File.exists?("#{var}/log/apache2/access_log")
touch("#{var}/log/apache2/error_log") unless File.exists?("#{var}/log/apache2/error_log")
end
def plist; <<-EOS.undent
<?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_prefix}/bin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
def httpd_layout
return <<-EOS.undent
<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}
sysconfdir: #{etc}/apache2/2.2
datadir: #{var}/www
installbuilddir: ${datadir}/build
errordir: ${datadir}/error
iconsdir: ${datadir}/icons
htdocsdir: ${datadir}/htdocs
manualdir: ${datadir}/manual
cgidir: #{var}/apache2/cgi-bin
includedir: ${prefix}/include/apache2
localstatedir: #{var}/apache2
runtimedir: #{var}/run/apache2
logfiledir: #{var}/log/apache2
proxycachedir: ${localstatedir}/proxy
</Layout>
EOS
end
test do
system sbin/"httpd", "-v"
end
def caveats
if build.with? "privileged-ports"
<<-EOS.undent
To load #{name} when --with-privileged-ports is used:
sudo cp -v #{plist_path} /Library/LaunchDaemons
sudo chown -v root:wheel /Library/LaunchDaemons/#{plist_path.basename}
sudo chmod -v 644 /Library/LaunchDaemons/#{plist_path.basename}
sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
To reload #{name} after an upgrade when --with-privileged-ports is used:
sudo launchctl unload /Library/LaunchDaemons/#{plist_path.basename}
sudo launchctl load /Library/LaunchDaemons/#{plist_path.basename}
If not using --with-privileged-ports, use the instructions below.
EOS
end
end
end