Hi Rodrigo,
I'm not sure what you are looking for, so I'll give you what worked for me.
My setup assumes you have built apr and apr-util from source beforehand, so
you may have to adjust accordingly.
In my (admittedly limited) experience, the best way is to unzip each httpd
and php version in their own folders. If you forget to "make clean" or
something similar, things will go wrong. Easiest is to just restart from
scratch each time.
You don't need a new httpd folder for each php version.
The way I build httpd (and I've been doing this for a while) is that I
delete the whole src folder and untar the whole release again each time,
followed by the ./configure and other commands.
For php, you don't need to rm/untar the whole folder every time and you can
just run this: "rm configure ; ./buildconf --force ; make clean". Or you
can rm/untar every time too, whatever you feel most comfortable with.
First build httpd in its own folder without regard for php, then build php
in its own folder by referencing the apxs2 you just built.
Before you begin, I'd suggest using a test machine and running each command
by hand. Please do NOT paste the whole script and expect it to work right
away.
For instance, recently I had this script for httpd (this method has worked
for me until v2.4.23, but for 2.4.23 you should now add @icing's patch for
the recent CVE-2016-8740, I just don't have the exact command at hand but
it should be along the lines of "patch -p1 < cve.diff"):
cd /usr/local/src ; rm -R httpd-2.4.23 ; tar -xjf httpd-2.4.23.tar.bz2
; cd /usr/local/src/httpd-2.4.23
./buildconf --with-apr=/usr/local/src/apr-1.5.2
--with-apr-util=/usr/local/src/apr-util-1.5.4
./configure --prefix=/usr/local/apache2 --with-program-name=apache2
--with-mpm=prefork --disable-cgi --disable-imap --with-ssl --with-pcre
--enable-mods-static="actions alias allowmethods auth-basic
auth-digest authn-core authn-file authz-core authz-host authz-user
autoindex cache deflate dir disk-cache dumpio env expires file-cache
filter headers http http2 include info logio log-config mem-cache mime
nghttp2-staticlib-deps negotiation proxy proxy-fcgi proxy-http rewrite
remoteip setenvif slotmem_shm so socache-shmcb ssl status substitute
unixd"
make && ./apache2 -V && ./apache2 -t -D DUMP_MODULES && ./apache2 -t
-D DUMP_VHOSTS
sudo service apache2 stop ; sudo make install && sudo service apache2 start
The above will build and install httpd in /usr/local/apache2.
Plus this one for php5:
cd /usr/local/src/php-5.6.28
rm -R ext/amqp 2>/dev/null ; mkdir ext/amqp ; cp -R ../amqp-1.7.1/* ext/amqp/
rm -R ext/geoip 2>/dev/null ; mkdir ext/geoip ; cp -R ../geoip-1.1.1/*
ext/geoip/
rm -R ext/http 2>/dev/null ; mkdir ext/http ; cp -R
../pecl_http-2.5.6/* ext/http/
rm -R ext/igbinary 2>/dev/null ; mkdir ext/igbinary ; cp -R
../igbinary-1.2.1/* ext/igbinary/
rm -R ext/redis 2>/dev/null ; mkdir ext/redis ; cp -R ../redis-2.2.8/*
ext/redis/
rm -R ext/raphf 2>/dev/null ; mkdir ext/raphf ; cp -R ../raphf-1.1.2/*
ext/raphf/
rm -R ext/propro 2>/dev/null ; mkdir ext/propro ; cp -R
../propro-1.0.2/* ext/propro/
rm -R ext/imagick 2>/dev/null ; mkdir ext/imagick ; cp -R
../imagick-3.4.1/* ext/imagick/
rm -R ext/timezonedb 2>/dev/null ; mkdir ext/timezonedb ; cp -R
../timezonedb-2016.9/* ext/timezonedb/
rm -R ext/ssh2 2>/dev/null ; mkdir ext/ssh2 ; cp -R ../ssh2-0.13/* ext/ssh2/
rm -R ext/libsodium 2>/dev/null ; mkdir ext/libsodium ; cp -R
../libsodium-php-1.0.6/* ext/libsodium/
cd /usr/local/src/php-5.6.28
rm configure ; ./buildconf --force ; make clean
./configure --prefix=/usr/local/php56 --disable-all
--with-apxs2=/usr/local/apache2/bin/apxs --with-iconv=/usr/local/lib
--with-icu-dir=/usr/local --enable-libxml --enable-xml --enable-dom
--enable-ctype --with-curl=/usr/local --enable-json --enable-session
--enable-simplexml --with-sqlite3 --enable-pdo --with-pdo-mysql
--with-pdo-sqlite --with-zlib=/usr/local --with-openssl --enable-soap
--enable-bcmath --with-bz2 --enable-calendar --enable-exif
--enable-ftp --with-gd --with-gettext --with-libxml-dir
--enable-mbstring --with-mcrypt --with-mhash --with-pcre-dir
--with-pcre-regex --enable-shmop --enable-sockets --enable-sysvmsg
--enable-sysvsem --enable-sysvshm --enable-wddx --with-xsl
--enable-zip --with-geoip --enable-filter --enable-hash
--enable-igbinary --with-mysqli --enable-tokenizer --enable-xmlreader
--enable-xmlwriter --enable-posix --enable-gd-native-ttf --with-t1lib
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local
--with-freetype-dir=/usr/local --with-vpx-dir=/usr/local
--with-imagick=/usr/local --enable-redis --disable-redis-session
--enable-redis-igbinary --enable-timezonedb --enable-fileinfo
--enable-intl --with-kerberos --enable-raphf --enable-propro
--with-http-libevent-dir=/usr/local --with-http --enable-opcache
--with-tidy --with-librabbitmq-dir=/usr/local --with-amqp
--with-libsodium --with-ssh2=shared
make && ./sapi/cli/php -m && ./sapi/cli/php -v
sudo make install && php56 -m && php56 -v
#sudo servi