Formatting code for ApacheSourceInstall
{{parent page="Apache"}}
Compiling and installing apache from source.
===Apache2.3.12-beta from source===
I built apr, apu, and openssl from source. The first two are needed because apache-2.3 requires apr-1.4 which is available with ubuntu11. Without these three, mod_ssl, mod_rewrite, and mod_auth_digest won't work. Openssl is built with the following options:
%%
sh config no-threads -fPIC --prefix=/opt/ssl
%%
Then compile apache
%%
./configure --enable-rewrite --disable-userdir \
--disable-negotiation --enable-vhost-alias --enable-info \
--enable-heartbeat --enable-heartmonitor --enable-lbmethod-heartbeat \
--enable-lbmethod-bybusyness --enable-lbmethod-bytraffic \
--enable-lbmethod-byrequests --enable-static-ab --enable-ssl \
--enable-proxy-ajp --enable-proxy-balancer --enable-proxy-http \
--enable-proxy-connect --enable-proxy --enable-deflate \
--enable-so --enable-cache --enable-disk-cache --enable-file-cache \
--enable-mods-shared=most --prefix=/usr/local/apache \
--with-apr=/usr/bin/apr-1-config --with-apr-util=/usr/bin/apu-1-config --with-ssl=/opt/ssl
# --enable-mpms-shared=event,prefork,worker
# --enable-privileges Per-virtualhost Unix UserIDs and enhanced security for Solaris
# heartbeat is still under development, perhaps I should skip them during compilation
%%
Here's what I have
%%
# httpd -V
Server version: Apache/2.3.5 (Unix)
Server built: Feb 24 2010 21:27:04
Server's Module Magic Number: 20091230:2
Server loaded: APR 1.4.3-dev, APR-UTIL 1.4.0-dev
Compiled using: APR 1.4.3-dev, APR-UTIL 1.4.0-dev
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
%%
===Apache2.2.11 build rpm===
Download the apache tar bz2 file
Edit httpd.spec and remove a tag that is not supported
Create a tgz archive
....
rpmbuild -tb httpd-2.2.11.tar.gz
===Apache2.2.4 quick compile (RedHat layout)===
%%
./configure --prefix=/etc/httpd --sysconfdir=/etc/httpd/conf \
--enable-mods-shared=all --enable-ssl --enable-rewrite --enable-proxy \
--enable-proxy-ajp --enable-cache --enable-disk-cache --enable-mem-cache \
--docdir=/var/www/html --enable-layout=RedHat \
--libexecdir=/usr/lib64/httpd --bindir=/usr/bin --sbindir=/usr/sbin \
--libdir=/usr/lib64 --includedir=/usr/include --enable-authn-dbm
# Optional
--with-mpm=worker : you need php compiled with thread safety (--enable-experimental-zts)
%%
and you'll need a proper init script
%%
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if LANG=C grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read /usr/share/doc/httpd-2.2.3/migration.html"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
%%
===Apache 2.0 compile===
%%
./configure --prefix=/opt/apache2 --enable-mods-shared=all \
--enable-ssl --enable-rewrite --enable-proxy --enable-deflate \
--enable-cache --enable-disk-cache --enable-file-cache --enable-mem-cache \
--enable-suexec
%%
Useful configure options
--enable-layout=xxx : check config.layout for detail
http://httpd.apache.org/docs/2.2/programs/configure.html
===Apache 1.3.x compile===
You will be needing the following packages:
apache_1.3.14.tar.gz http://www.apache.org
openssl-0.9.6.tar.gz http://www.openssl.org
mod_ssl-2.7.1-1.3.14.tar.gz http://www.modssl.org
mm-1.1.3.tar.gz http://www.engelschall.com/sw/mm
==Installing the prerequisites==
openssl
%%
sh config -fPIC
make -j2
make install
%%
mm
%%
./configure --disable-shared
make
make install
%%
==Apache and mod_ssl==
Apache
%%
./configure --enable-module=so --enable-module=proxy
make -j2
make install
%%
mod_ssl
%%
./configure \
--with-apache=../$apache_ver \
--with-ssl=../$ssl_ver \
--with-mm=../$mm_ver \
--prefix=/usr/local/apache \
--enable-shared=ssl \
--enable-module=proxy
or
./configure \
--with-apache=../apache_1.3.x \
--expert --with-ssl=/usr
%%
Back to Apache
%%
make -j2
make certificate
make install
or
env CFLAGS="-Wall -DHARD_SERVER_LIMIT=1024" ./configure \
--prefix=/usr/local/apache \
--enable-module=so \
--enable-shared=max \
--enable-module=ssl
%%
==Install from FreeBSD ports==
%%
cd /usr/ports/www/apache22/
make config install distclean
echo 'apache2_enable="YES"' >> /etc/rc.conf
echo 'apache2ssl_enable="YES"' >> /etc/rc.conf
echo 'accf_http_ready="YES"' >> /etc/rc.conf && kldload accf_http
%%
==What about stupid solaris?==
What does this tell you? Everything that comes with solaris by default don't fking work.
%%
env PATH=/usr/bin:/usr/ccs/bin:/opt/SUNWspro/bin \
CC=cc CFLAGS=-fast CPPFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
./configure --prefix=/usr/local/apache2 --enable-mods-shared=all \
--enable-ssl --enable-rewrite --enable-proxy --enable-proxy-ajp \
--enable-cache --enable-disk-cache --enable-mem-cache \
--with-mpm=worker
%%
Compiling and installing apache from source.
===Apache2.3.12-beta from source===
I built apr, apu, and openssl from source. The first two are needed because apache-2.3 requires apr-1.4 which is available with ubuntu11. Without these three, mod_ssl, mod_rewrite, and mod_auth_digest won't work. Openssl is built with the following options:
%%
sh config no-threads -fPIC --prefix=/opt/ssl
%%
Then compile apache
%%
./configure --enable-rewrite --disable-userdir \
--disable-negotiation --enable-vhost-alias --enable-info \
--enable-heartbeat --enable-heartmonitor --enable-lbmethod-heartbeat \
--enable-lbmethod-bybusyness --enable-lbmethod-bytraffic \
--enable-lbmethod-byrequests --enable-static-ab --enable-ssl \
--enable-proxy-ajp --enable-proxy-balancer --enable-proxy-http \
--enable-proxy-connect --enable-proxy --enable-deflate \
--enable-so --enable-cache --enable-disk-cache --enable-file-cache \
--enable-mods-shared=most --prefix=/usr/local/apache \
--with-apr=/usr/bin/apr-1-config --with-apr-util=/usr/bin/apu-1-config --with-ssl=/opt/ssl
# --enable-mpms-shared=event,prefork,worker
# --enable-privileges Per-virtualhost Unix UserIDs and enhanced security for Solaris
# heartbeat is still under development, perhaps I should skip them during compilation
%%
Here's what I have
%%
# httpd -V
Server version: Apache/2.3.5 (Unix)
Server built: Feb 24 2010 21:27:04
Server's Module Magic Number: 20091230:2
Server loaded: APR 1.4.3-dev, APR-UTIL 1.4.0-dev
Compiled using: APR 1.4.3-dev, APR-UTIL 1.4.0-dev
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
%%
===Apache2.2.11 build rpm===
Download the apache tar bz2 file
Edit httpd.spec and remove a tag that is not supported
Create a tgz archive
....
rpmbuild -tb httpd-2.2.11.tar.gz
===Apache2.2.4 quick compile (RedHat layout)===
%%
./configure --prefix=/etc/httpd --sysconfdir=/etc/httpd/conf \
--enable-mods-shared=all --enable-ssl --enable-rewrite --enable-proxy \
--enable-proxy-ajp --enable-cache --enable-disk-cache --enable-mem-cache \
--docdir=/var/www/html --enable-layout=RedHat \
--libexecdir=/usr/lib64/httpd --bindir=/usr/bin --sbindir=/usr/sbin \
--libdir=/usr/lib64 --includedir=/usr/include --enable-authn-dbm
# Optional
--with-mpm=worker : you need php compiled with thread safety (--enable-experimental-zts)
%%
and you'll need a proper init script
%%
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if LANG=C grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read /usr/share/doc/httpd-2.2.3/migration.html"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
%%
===Apache 2.0 compile===
%%
./configure --prefix=/opt/apache2 --enable-mods-shared=all \
--enable-ssl --enable-rewrite --enable-proxy --enable-deflate \
--enable-cache --enable-disk-cache --enable-file-cache --enable-mem-cache \
--enable-suexec
%%
Useful configure options
--enable-layout=xxx : check config.layout for detail
http://httpd.apache.org/docs/2.2/programs/configure.html
===Apache 1.3.x compile===
You will be needing the following packages:
apache_1.3.14.tar.gz http://www.apache.org
openssl-0.9.6.tar.gz http://www.openssl.org
mod_ssl-2.7.1-1.3.14.tar.gz http://www.modssl.org
mm-1.1.3.tar.gz http://www.engelschall.com/sw/mm
==Installing the prerequisites==
openssl
%%
sh config -fPIC
make -j2
make install
%%
mm
%%
./configure --disable-shared
make
make install
%%
==Apache and mod_ssl==
Apache
%%
./configure --enable-module=so --enable-module=proxy
make -j2
make install
%%
mod_ssl
%%
./configure \
--with-apache=../$apache_ver \
--with-ssl=../$ssl_ver \
--with-mm=../$mm_ver \
--prefix=/usr/local/apache \
--enable-shared=ssl \
--enable-module=proxy
or
./configure \
--with-apache=../apache_1.3.x \
--expert --with-ssl=/usr
%%
Back to Apache
%%
make -j2
make certificate
make install
or
env CFLAGS="-Wall -DHARD_SERVER_LIMIT=1024" ./configure \
--prefix=/usr/local/apache \
--enable-module=so \
--enable-shared=max \
--enable-module=ssl
%%
==Install from FreeBSD ports==
%%
cd /usr/ports/www/apache22/
make config install distclean
echo 'apache2_enable="YES"' >> /etc/rc.conf
echo 'apache2ssl_enable="YES"' >> /etc/rc.conf
echo 'accf_http_ready="YES"' >> /etc/rc.conf && kldload accf_http
%%
==What about stupid solaris?==
What does this tell you? Everything that comes with solaris by default don't fking work.
%%
env PATH=/usr/bin:/usr/ccs/bin:/opt/SUNWspro/bin \
CC=cc CFLAGS=-fast CPPFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
./configure --prefix=/usr/local/apache2 --enable-mods-shared=all \
--enable-ssl --enable-rewrite --enable-proxy --enable-proxy-ajp \
--enable-cache --enable-disk-cache --enable-mem-cache \
--with-mpm=worker
%%