1%define contentdir /var/www
2%define suexec_caller apache
3%define mmn 20051115
4%define mpms worker event
5
6Summary: Apache HTTP Server
7Name: httpd
8Version: 2.2.26
9Release: 1
10URL: http://httpd.apache.org/
11Vendor: Apache Software Foundation
12Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.gz
13License: Apache License, Version 2.0
14Group: System Environment/Daemons
15BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
16BuildPrereq: apr-devel, apr-util-devel, openldap-devel, db4-devel, expat-devel, findutils, perl, pkgconfig, pcre-devel >= 5.0
17BuildPrereq: /usr/bin/apr-1-config, /usr/bin/apu-1-config
18Requires: apr >= 1.4.2, apr-util >= 1.3.10, pcre >= 5.0, gawk, /usr/bin/find, openldap
19Prereq: /sbin/chkconfig, /bin/mktemp, /bin/rm, /bin/mv
20Prereq: sh-utils, textutils, /usr/sbin/useradd
21Provides: webserver
22Provides: httpd-mmn = %{mmn}
23Conflicts: thttpd
24Obsoletes: apache, secureweb, mod_dav
25
26%description
27Apache is a powerful, full-featured, efficient, and freely-available
28Web server. Apache is also the most popular Web server on the
29Internet.
30
31%package devel
32Group: Development/Libraries
33Summary: Development tools for the Apache HTTP server.
34Obsoletes: secureweb-devel, apache-devel
35Requires: libtool, httpd = %{version}
36Requires: apr-devel >= 1.4.2, apr-util-devel >= 1.3.10
37
38%description devel
39The httpd-devel package contains the APXS binary and other files
40that you need to build Dynamic Shared Objects (DSOs) for Apache.
41
42If you are installing the Apache HTTP server and you want to be
43able to compile or develop additional modules for Apache, you need
44to install this package.
45
46%package manual
47Group: Documentation
48Summary: Documentation for the Apache HTTP server.
49Obsoletes: secureweb-manual, apache-manual
50
51%description manual
52The httpd-manual package contains the complete manual and
53reference guide for the Apache HTTP server. The information can
54also be found at http://httpd.apache.org/docs/.
55
56%package -n mod_ssl
57Group: System Environment/Daemons
58Summary: SSL/TLS module for the Apache HTTP server
59BuildPrereq: openssl-devel
60Prereq: openssl, dev, /bin/cat
61Requires: httpd, make, httpd-mmn = %{mmn}
62
63%description -n mod_ssl
64The mod_ssl module provides strong cryptography for the Apache Web
65server via the Secure Sockets Layer (SSL) and Transport Layer
66Security (TLS) protocols.
67
68%prep
69%setup -q
70
71# Safety check: prevent build if defined MMN does not equal upstream MMN.
72vmmn=`echo MODULE_MAGIC_NUMBER_MAJOR | cpp -include include/ap_mmn.h | sed -n '
73/^2/p'`
74if test "x${vmmn}" != "x%{mmn}"; then
75   : Error: Upstream MMN is now ${vmmn}, packaged MMN is %{mmn}.
76   : Update the mmn macro and rebuild.
77   exit 1
78fi
79
80%build
81# forcibly prevent use of bundled apr, apr-util, pcre
82rm -rf srclib/{apr,apr-util,pcre}
83
84# Before configure; fix location of build dir in generated apxs
85%{__perl} -pi -e "s:\@exp_installbuilddir\@:%{_libdir}/httpd/build:g" \
86	support/apxs.in
87
88function mpmbuild()
89{
90mpm=$1; shift
91mkdir $mpm; pushd $mpm
92../configure \
93 	--prefix=%{_sysconfdir}/httpd \
94        --with-apr=/usr/bin/apr-1-config \
95        --with-apr-util=/usr/bin/apu-1-config \
96        --with-pcre=/usr/bin/pcre-config \
97        --exec-prefix=%{_prefix} \
98 	--bindir=%{_bindir} \
99 	--sbindir=%{_sbindir} \
100 	--mandir=%{_mandir} \
101	--libdir=%{_libdir} \
102	--sysconfdir=%{_sysconfdir}/httpd/conf \
103	--includedir=%{_includedir}/httpd \
104	--libexecdir=%{_libdir}/httpd/modules \
105	--datadir=%{contentdir} \
106        --with-installbuilddir=%{_libdir}/httpd/build \
107	--with-mpm=$mpm \
108	--enable-suexec --with-suexec \
109	--with-suexec-caller=%{suexec_caller} \
110	--with-suexec-docroot=%{contentdir} \
111	--with-suexec-logfile=%{_localstatedir}/log/httpd/suexec.log \
112	--with-suexec-bin=%{_sbindir}/suexec \
113	--with-suexec-uidmin=500 --with-suexec-gidmin=500 \
114	--enable-pie \
115	--with-pcre \
116	$*
117
118make %{?_smp_mflags}
119popd
120}
121
122 # Build everything and the kitchen sink with the prefork build
123mpmbuild prefork \
124        --enable-mods-shared=all \
125        --enable-ssl --with-ssl --enable-distcache \
126        --enable-proxy \
127        --enable-cache \
128        --enable-disk-cache \
129        --enable-ldap --enable-authnz-ldap \
130        --enable-cgid \
131        --enable-authn-anon --enable-authn-alias \
132        --disable-imagemap
133
134# For the other MPMs, just build httpd and no optional modules
135for f in %{mpms}; do
136   mpmbuild $f --enable-mods-shared=all
137done
138
139%install
140rm -rf $RPM_BUILD_ROOT
141
142pushd prefork
143make DESTDIR=$RPM_BUILD_ROOT install
144popd
145
146# install alternative MPMs
147for f in %{mpms}; do
148  install -m 755 ${f}/httpd $RPM_BUILD_ROOT%{_sbindir}/httpd.${f}
149done
150
151# for holding mod_dav lock database
152mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/dav
153
154# create a prototype session cache
155mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/mod_ssl
156touch $RPM_BUILD_ROOT%{_localstatedir}/cache/mod_ssl/scache.{dir,pag,sem}
157
158# move the build directory to within the library directory
159mv $RPM_BUILD_ROOT%{contentdir}/build $RPM_BUILD_ROOT%{_libdir}/httpd/build
160
161# Make the MMN accessible to module packages
162echo %{mmn} > $RPM_BUILD_ROOT%{_includedir}/httpd/.mmn
163
164# docroot
165mkdir $RPM_BUILD_ROOT%{contentdir}/html
166
167# Set up /var directories
168rmdir $RPM_BUILD_ROOT%{_sysconfdir}/httpd/logs
169mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/httpd
170mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/httpd/cache-root
171
172# symlinks for /etc/httpd
173ln -s ../..%{_localstatedir}/log/httpd $RPM_BUILD_ROOT/etc/httpd/logs
174ln -s ../..%{_localstatedir}/run $RPM_BUILD_ROOT/etc/httpd/run
175ln -s ../..%{_libdir}/httpd/modules $RPM_BUILD_ROOT/etc/httpd/modules
176
177# install SYSV init stuff
178mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
179install -m755 ./build/rpm/httpd.init \
180	$RPM_BUILD_ROOT/etc/rc.d/init.d/httpd
181install -m755 ./build/rpm/htcacheclean.init \
182        $RPM_BUILD_ROOT/etc/rc.d/init.d/htcacheclean
183
184# install log rotation stuff
185mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
186install -m644 ./build/rpm/httpd.logrotate \
187	$RPM_BUILD_ROOT/etc/logrotate.d/httpd
188
189# Remove unpackaged files
190rm -rf $RPM_BUILD_ROOT%{_libdir}/httpd/modules/*.exp \
191       $RPM_BUILD_ROOT%{contentdir}/htdocs/* \
192       $RPM_BUILD_ROOT%{contentdir}/cgi-bin/* 
193
194# Make suexec a+rw so it can be stripped.  %%files lists real permissions
195chmod 755 $RPM_BUILD_ROOT%{_sbindir}/suexec
196
197%pre
198# Add the "apache" user
199/usr/sbin/useradd -c "Apache" -u 48 \
200	-s /sbin/nologin -r -d %{contentdir} apache 2> /dev/null || :
201
202%post
203# Register the httpd service
204/sbin/chkconfig --add httpd
205/sbin/chkconfig --add htcacheclean
206
207%preun
208if [ $1 = 0 ]; then
209	/sbin/service httpd stop > /dev/null 2>&1
210        /sbin/service htcacheclean stop > /dev/null 2>&1
211	/sbin/chkconfig --del httpd
212        /sbin/chkconfig --del htcacheclean
213fi
214
215%post -n mod_ssl
216umask 077
217
218if [ ! -f %{_sysconfdir}/httpd/conf/server.key ] ; then
219%{_bindir}/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > %{_sysconfdir}/httpd/conf/server.key 2> /dev/null
220fi
221
222FQDN=`hostname`
223if [ "x${FQDN}" = "x" ]; then
224   FQDN=localhost.localdomain
225fi
226
227if [ ! -f %{_sysconfdir}/httpd/conf/server.crt ] ; then
228cat << EOF | %{_bindir}/openssl req -new -key %{_sysconfdir}/httpd/conf/server.key -x509 -days 365 -out %{_sysconfdir}/httpd/conf/server.crt 2>/dev/null
229--
230SomeState
231SomeCity
232SomeOrganization
233SomeOrganizationalUnit
234${FQDN}
235root@${FQDN}
236EOF
237fi
238
239%check
240# Check the built modules are all PIC
241if readelf -d $RPM_BUILD_ROOT%{_libdir}/httpd/modules/*.so | grep TEXTREL; then
242   : modules contain non-relocatable code
243   exit 1
244fi
245
246# Verify that the same modules were built into the httpd binaries
247./prefork/httpd -l | grep -v prefork > prefork.mods
248for mpm in %{mpms}; do
249  ./${mpm}/httpd -l | grep -v ${mpm} > ${mpm}.mods
250  if ! diff -u prefork.mods ${mpm}.mods; then
251    : Different modules built into httpd binaries, will not proceed
252    exit 1
253  fi
254done
255
256%clean
257rm -rf $RPM_BUILD_ROOT
258
259%files
260%defattr(-,root,root)
261
262%doc ABOUT_APACHE README CHANGES LICENSE NOTICE
263
264%dir %{_sysconfdir}/httpd
265%{_sysconfdir}/httpd/modules
266%{_sysconfdir}/httpd/logs
267%{_sysconfdir}/httpd/run
268%dir %{_sysconfdir}/httpd/conf
269%config(noreplace) %{_sysconfdir}/httpd/conf/httpd.conf
270%config(noreplace) %{_sysconfdir}/httpd/conf/magic
271%config(noreplace) %{_sysconfdir}/httpd/conf/mime.types
272%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-autoindex.conf
273%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-dav.conf
274%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-default.conf
275%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-info.conf
276%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-languages.conf
277%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-manual.conf
278%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-mpm.conf
279%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-multilang-errordoc.conf
280%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-userdir.conf
281%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-vhosts.conf
282%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-autoindex.conf
283%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-dav.conf
284%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-default.conf
285%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-info.conf
286%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-languages.conf
287%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-manual.conf
288%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-mpm.conf
289%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-multilang-errordoc.conf
290%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-userdir.conf
291%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-vhosts.conf
292%config(noreplace) %{_sysconfdir}/httpd/conf/original/httpd.conf
293
294%config %{_sysconfdir}/logrotate.d/httpd
295%config %{_sysconfdir}/rc.d/init.d/httpd
296%config %{_sysconfdir}/rc.d/init.d/htcacheclean
297
298%{_sbindir}/ab
299%{_sbindir}/htcacheclean
300%{_sbindir}/htdbm
301%{_sbindir}/htdigest
302%{_sbindir}/htpasswd
303%{_sbindir}/logresolve
304%{_sbindir}/httpd
305%{_sbindir}/httpd.worker
306%{_sbindir}/httpd.event
307%{_sbindir}/httxt2dbm
308%{_sbindir}/apachectl
309%{_sbindir}/rotatelogs
310%attr(4510,root,%{suexec_caller}) %{_sbindir}/suexec
311
312%dir %{_libdir}/httpd
313%dir %{_libdir}/httpd/modules
314# everything but mod_ssl.so:
315%{_libdir}/httpd/modules/mod_[a-r]*.so
316%{_libdir}/httpd/modules/mod_s[petu]*.so
317%{_libdir}/httpd/modules/mod_[t-z]*.so
318
319%dir %{contentdir}
320%dir %{contentdir}/cgi-bin
321%dir %{contentdir}/html
322%dir %{contentdir}/icons
323%dir %{contentdir}/error
324%dir %{contentdir}/error/include
325%{contentdir}/icons/*
326%{contentdir}/error/README
327%config(noreplace) %{contentdir}/error/*.var
328%config(noreplace) %{contentdir}/error/include/*.html
329
330%attr(0700,root,root) %dir %{_localstatedir}/log/httpd
331
332%attr(0700,apache,apache) %dir %{_localstatedir}/lib/dav
333%attr(0700,apache,apache) %dir %{_localstatedir}/cache/httpd/cache-root
334
335%{_mandir}/man1/*
336%{_mandir}/man8/ab*
337%{_mandir}/man8/rotatelogs*
338%{_mandir}/man8/logresolve*
339%{_mandir}/man8/suexec*
340%{_mandir}/man8/apachectl.8*
341%{_mandir}/man8/httpd.8*
342%{_mandir}/man8/htcacheclean.8*
343
344%files manual
345%defattr(-,root,root)
346%{contentdir}/manual
347%{contentdir}/error/README
348
349%files -n mod_ssl
350%defattr(-,root,root)
351%{_libdir}/httpd/modules/mod_ssl.so
352%config(noreplace) %{_sysconfdir}/httpd/conf/original/extra/httpd-ssl.conf
353%config(noreplace) %{_sysconfdir}/httpd/conf/extra/httpd-ssl.conf
354%attr(0700,apache,root) %dir %{_localstatedir}/cache/mod_ssl
355%attr(0600,apache,root) %ghost %{_localstatedir}/cache/mod_ssl/scache.dir
356%attr(0600,apache,root) %ghost %{_localstatedir}/cache/mod_ssl/scache.pag
357%attr(0600,apache,root) %ghost %{_localstatedir}/cache/mod_ssl/scache.sem
358
359%files devel
360%defattr(-,root,root)
361%{_includedir}/httpd
362%{_sbindir}/apxs
363%{_sbindir}/checkgid
364%{_sbindir}/dbmmanage
365%{_sbindir}/envvars*
366%{_mandir}/man8/apxs.8*
367%dir %{_libdir}/httpd/build
368%{_libdir}/httpd/build/*.mk
369%{_libdir}/httpd/build/instdso.sh
370%{_libdir}/httpd/build/config.nice
371%{_libdir}/httpd/build/mkdir.sh
372
373