Compiling Apache 2.2.29

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting you must declare the environment variables specified at the link above.

#building env vars (required when rebuilding too)
APACHE_MPM=worker
NEW_BUILD_NAME=apache
NEW_BUILD_VER=2.2.29-$APACHE_MPM
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=10

#extract sources
rm -r ~/compile/httpd-2.2.29-unpacked
cd ~/compile && mkdir httpd-2.2.29-unpacked
tar xvzf httpd-2.2.29.tar.gz -C ./httpd-2.2.29-unpacked
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29

#If any additional problems related to libtool see below.
#Modify "configure.in" and "configure" (search for: "case $libtoolversion in"):
  case $libtoolversion in
	  *1.[45]*)
		  SH_LIBTOOL='$(LIBTOOL)'
		  SHLTCFLAGS="-prefer-pic"
		  LTCFLAGS="-prefer-non-pic -static"
		  ;;
	  *)
		  //pedro: setez cumva SH_LIBTOOL
		  //SH_LIBTOOL='$(SHELL) $(top_builddir)/shlibtool $(LTFLAGS)' -> comenteaza (nu exista shlibtool)
		  SH_LIBTOOL='/ffp/lib/apr-1.4.8/build-1/libtool $(LTFLAGS)' -> to add
		  SHLTCFLAGS=""
		  LTCFLAGS=""
		  ;;
  esac

#Enable NPN
#https://issues.apache.org/bugzilla/show_bug.cgi?id=52210
#http://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x/
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29
wget https://issues.apache.org/bugzilla/attachment.cgi?id=28588 -O npn.patch
#Modify npn.patch:
	Index: modules/ssl/ssl_engine_kernel.c
	===================================================================
	--- modules/ssl/ssl_engine_kernel.c	(revision 1306012)
	+++ modules/ssl/ssl_engine_kernel.c	(working copy)
	@@ -29,5 +29,6 @@
									   time I was too famous.''
												 -- Unknown                */
	 #include "ssl_private.h"
	+#include "mod_ssl.h"
	 
	 static void ssl_configure_env(request_rec *r, SSLConnRec *sslconn);
patch -p0 -i npn.patch

#Enable mod_fcgid
rm -r ~/compile/mod_fcgid
cd ~/compile/
svn checkout http://svn.apache.org/repos/asf/httpd/mod_fcgid/trunk mod_fcgid
cp -r ~/compile/mod_fcgid/modules/fcgid ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29/modules/

#Enable WebSocket with mod_proxy_wstunnel
#http://notmyitblog.blogspot.ro/2014/03/websockets-support-for-apache-httpd.html
#https://gist.github.com/vitkin/6661683
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29
wget https://gist.github.com/vitkin/6661683/raw/873dd8b4de4ad1ff69757ffe48fc574374aedc57/apache-2.2-wstunnel.patch -O apache-2.2-wstunnel.patch
patch -p1 -i apache-2.2-wstunnel.patch
#cp -r httpd-2.2.29 httpd-2.2.29-fcgid-npn-wstunnel
#You may encounter some compilation error with version 2.2.22 and later similar to:
#modules/http/.libs/libmod_http.a(byterange_filter.o): In function `ap_set_byterange':
#byterange_filter.c:(.text+0x130d): undefined reference to `apr_array_clear'
#collect2: ld returned 1 exit status
#This is a known bug. A workaround consist in adding --with-included-apr to the configure options.

#configure new added modules (fcgid)
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29
~/x.sh ffpg
./buildconf
~/x.sh ffpg

#start from here when REBUILDING (only if not deleted ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29)
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29
rm -r ../httpd-2.2.29-build
mkdir ../httpd-2.2.29-build

#CONFIGURE
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29-build
../httpd-2.2.29/configure --help > ../configure.help.txt
#../httpd-2.2.29/configure --prefix=/ffp/opt/apache-2.2.29-$APACHE_MPM --enable-mods-shared=all --with-apr=/ffp --with-apr-util=/ffp --with-pcre=/ffp --with-z=/ffp --with-ssl=/ffp --with-mpm=$APACHE_MPM --enable-fcgid
../httpd-2.2.29/configure --prefix=/ffp/opt/apache-2.2.29-$APACHE_MPM --enable-modules="log_config mime alias autoindex headers authz_host userdir env setenvif filter authn_file ssl actions dir negotiation auth_basic authz_default authz_user rewrite proxy proxy_http proxy_ajp dav dav_svn authz_svn expires deflate info dav_fs proxy_wstunnel" --enable-mods-shared="fcgid asis authn_default authz_groupfile cache cgi cgid disk_cache file_cache include mem_cache proxy_balancer proxy_connect proxy_ftp proxy_scgi status version" --with-pcre=/ffp --with-z=/ffp --with-ssl=/ffp --with-mpm=$APACHE_MPM --enable-fcgid

#prepare for FFP again
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29-build
~/x.sh ffpg1
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29
~/x.sh ffpg

#COMPILE
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29-build
nohup /ffp/bin/make -C ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29-build &
renice -6 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1`
tail -f nohup.out

#INSTALL & PACKAGE
cd ~/compile/httpd-2.2.29-unpacked/httpd-2.2.29-build
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
#Running make -n install permits previewing the build process, as it prints out all 
#the commands that would be triggered by a make, without actually executing them.
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

#copy additional modules
cd $HOME
sed -i s/"User daemon"/"User nobody"/ /ffp/opt/apache-2.2.29-$APACHE_MPM/conf/httpd.conf
sed -i s/"Group daemon"/"Group nobody"/ /ffp/opt/apache-2.2.29-$APACHE_MPM/conf/httpd.conf
mkdir /ffp/opt/apache-2.2.29-$APACHE_MPM/conf-original
cp -r /ffp/opt/apache-2.2.29-$APACHE_MPM/conf/* /ffp/opt/apache-2.2.29-$APACHE_MPM/conf-original
cp -v /ffp/libexec/mod_authz_svn.so /ffp/opt/apache-2.2.29-$APACHE_MPM/modules/
cp -v /ffp/libexec/mod_dav_svn.so /ffp/opt/apache-2.2.29-$APACHE_MPM/modules/
ls -dl ~/NSA310-backups/*apache-modules*
cp -v ~/NSA310-backups/2015-02-01\ apache-modules\ worker/*.so /ffp/opt/apache-2.2.29-$APACHE_MPM/modules/
ls -dl ~/NSA310-backups/*pagespeed*
cp -v ~/NSA310-backups/2015-01-23\ pagespeed\ trunk/*.so /ffp/opt/apache-2.2.29-$APACHE_MPM/modules/

#INFO
#lists configured httpd modules:
#/usr/sbin/httpd -M -f /etc/service_conf/httpd.conf
#/ffp/opt/apache-2.2.29-worker/bin/httpd -M -f /etc/service_conf/xhttpd.conf
#lists built-in httpd modules:
#/usr/sbin/httpd -l
#/ffp/opt/apache-2.2.29-worker/bin/httpd -l

#owncloud, apache, php-zts and fcgid
#If fcgid is not a shared module (--enable-mods-shared) than after logging off 
#from owncloud you won't be able to login again (you'll have to restart apache).
#Does not have this problem when using php-non-zts.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.