Skip to content

Commit

Permalink
Apache 2.4.8 Event MPM, mod_fastcgi, PHP-FPM over unix sockets, latest
Browse files Browse the repository at this point in the history
beta APC (otherwise segfaults), PCRE, APR, APR-util

Updating README with somewhat improved instructions
  • Loading branch information
winglian authored and Wing Lian committed Oct 23, 2012
1 parent 657ca54 commit a496bbf
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 98 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ The config files are bundled with the buildpack itself:
* conf/httpd.conf
* conf/php.ini

Configure Heroku to use this buildpack repo AND branch

heroku config:set BUILDPACK_URL=git://github.com/winglian/heroku-buildpack-php.git#mpm-event-php-fpm

Pre-compiling binaries
----------------------

After building the binary below, update the OPT_BUILDPACK_URL variable in bin/compile to point to the url of the vulcan binary from Heroku

vulcan build -v -s ./build -p /tmp/build -c "./vulcan.sh"
cp /tmp/build.tgz src/build.tgz

Hacking
-------

To change this buildpack, fork it on Github. Push up changes to your fork, then create a test app with --buildpack <your-github-url> and push to it.


Meta
----

Expand Down
15 changes: 10 additions & 5 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
set -e

# config
APACHE_VERSION="2.2.23"
APACHE_VERSION="2.4.3"
APACHE_PATH="apache"
PHP_VERSION="5.3.17"
PHP_VERSION="5.4.8"
PHP_PATH="php"
BUILDPACK_VERSION="1.2"

BUILDPACK_VERSION="2.0-a3"
OPT_BUILDPACK_URL="http://vulcan-wlian.herokuapp.com/output/3769458a-2650-4189-a50f-f3bd9c685c75"

BIN_DIR=$(dirname $0)
BUILD_DIR=$1
Expand All @@ -34,7 +34,8 @@ fi

BP_URL="https://s3.amazonaws.com/licorice-labs-buildpacks/apache-$APACHE_VERSION-php-$PHP_VERSION-v$BUILDPACK_VERSION.tar.gz"
echo "-----> Bundling Apache $APACHE_VERSION PHP $PHP_VERSION build $BUILDPACK_VERSION"
curl --silent --max-time 60 --location "$BP_URL" | tar xz
# curl --silent --max-time 60 --location "$BP_URL" | tar xz
curl --silent --max-time 60 --location "$OPT_BUILDPACK_URL" | tar xz

# echo "-----> Extracting bsdiff binary"
# tar xzf $LP_DIR/src/bsdiff.tgz
Expand All @@ -46,6 +47,7 @@ curl --silent --max-time 60 --location "$BP_URL" | tar xz
# update config files
cp $LP_DIR/conf/httpd.conf $APACHE_PATH/conf
cp $LP_DIR/conf/php.ini php
cp $LP_DIR/conf/php-fpm.conf $BUILD_DIR/php/etc/

# make php available on bin
mkdir -p bin
Expand Down Expand Up @@ -86,6 +88,9 @@ if [ -d www/.hooks ]; then
done
fi
echo "Launching PHP FPM"
/app/php/sbin/php-fpm -y /app/php/etc/php-fpm.conf -c /app/php/php.ini
echo "Launching apache"
exec /app/apache/bin/httpd -DNO_DETACH
EOF
Expand Down
73 changes: 51 additions & 22 deletions build/vulcan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ mkdir /app/local/bin
mkdir /app/local/include
mkdir /app/apache
mkdir /app/php
mkdir /app/php/ext

cd /tmp
curl -O http://mirrors.us.kernel.org/ubuntu//pool/universe/m/mcrypt/mcrypt_2.6.8-1_amd64.deb
curl -O http://mirrors.us.kernel.org/ubuntu//pool/universe/libm/libmcrypt/libmcrypt4_2.5.8-3.1_amd64.deb
curl -O http://mirrors.us.kernel.org/ubuntu//pool/universe/libm/libmcrypt/libmcrypt-dev_2.5.8-3.1_amd64.deb
curl -O http://mirrors.us.kernel.org/ubuntu/pool/universe/m/mcrypt/mcrypt_2.6.8-1_amd64.deb
curl -O http://mirrors.us.kernel.org/ubuntu/pool/universe/libm/libmcrypt/libmcrypt4_2.5.8-3.1_amd64.deb
curl -O http://mirrors.us.kernel.org/ubuntu/pool/universe/libm/libmcrypt/libmcrypt-dev_2.5.8-3.1_amd64.deb
ls -tr *.deb > packages.txt
while read l; do
ar x $l
Expand All @@ -23,18 +22,39 @@ done < packages.txt
cp -a /tmp/usr/include/* /app/local/include
cp -a /tmp/usr/lib/* /app/local/lib

# export APACHE_MIRROR_HOST="http://www.apache.org/dist"
export APACHE_MIRROR_HOST="http://apache.mirrors.tds.net"

# curl -L ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz -o /tmp/libmcrypt-2.5.7.tar.gz
# curl -L ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.25.tar.gz -o /tmp/cyrus-sasl-2.1.25.tar.gz
curl -L https://launchpad.net/libmemcached/1.0/1.0.11/+download/libmemcached-1.0.11.tar.gz -o /tmp/libmemcached-1.0.11.tar.gz
curl -L http://www.apache.org/dist/httpd/httpd-2.2.23.tar.gz -o /tmp/httpd-2.2.23.tar.gz
curl -L http://us.php.net/get/php-5.3.17.tar.gz/from/us2.php.net/mirror -o /tmp/php-5.3.17.tar.gz
echo "downloading libmemcached"
curl -L https://launchpad.net/libmemcached/1.0/1.0.13/+download/libmemcached-1.0.13.tar.gz -o /tmp/libmemcached-1.0.13.tar.gz
echo "downloading PCRE"
curl -L ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz -o /tmp/pcre-8.31.tar.gz
echo "downloading apr"
curl -L ${APACHE_MIRROR_HOST}/apr/apr-1.4.6.tar.gz -o /tmp/apr-1.4.6.tar.gz
echo "downloading apr-util"
curl -L ${APACHE_MIRROR_HOST}/apr/apr-util-1.5.1.tar.gz -o /tmp/apr-util-1.5.1.tar.gz
echo "downloading httpd"
curl -L ${APACHE_MIRROR_HOST}/httpd/httpd-2.4.3.tar.gz -o /tmp/httpd-2.4.3.tar.gz
echo "downloading php"
curl -L http://us.php.net/get/php-5.4.8.tar.gz/from/us2.php.net/mirror -o /tmp/php-5.4.8.tar.gz
echo "downloading pecl-memcached"
curl -L http://pecl.php.net/get/memcached-2.1.0.tgz -o /tmp/memcached-2.1.0.tgz

# tar -C /tmp -xzf /tmp/libmcrypt-2.5.7.tar.gz
# tar -C /tmp -xzf /tmp/cyrus-sasl-2.1.25.tar.gz
tar -C /tmp -xzf /tmp/libmemcached-1.0.11.tar.gz
tar -C /tmp -xzf /tmp/httpd-2.2.23.tar.gz
tar -C /tmp -xzf /tmp/php-5.3.17.tar.gz
tar -C /tmp -xzf /tmp/libmemcached-1.0.13.tar.gz
tar -C /tmp -xzf /tmp/pcre-8.31.tar.gz
tar -C /tmp -xzf /tmp/httpd-2.4.3.tar.gz

tar -C /tmp/httpd-2.4.3/srclib -xzf /tmp/apr-1.4.6.tar.gz
mv /tmp/httpd-2.4.3/srclib/apr-1.4.6 /tmp/httpd-2.4.3/srclib/apr

tar -C /tmp/httpd-2.4.3/srclib -xzf /tmp/apr-util-1.5.1.tar.gz
mv /tmp/httpd-2.4.3/srclib/apr-util-1.5.1 /tmp/httpd-2.4.3/srclib/apr-util

tar -C /tmp -xzf /tmp/php-5.4.8.tar.gz
tar -C /tmp -xzf /tmp/memcached-2.1.0.tgz

export CFLAGS='-g0 -O2 -s -m64 -march=core2 -mtune=generic -pipe '
Expand All @@ -48,33 +68,41 @@ export MAKE_CMD="/usr/bin/make $MAKEFLAGS"
# ./configure --prefix=/app/local --disable-posix-threads --enable-dynamic-loading --enable-static-link
# ${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/httpd-2.2.23
./configure --prefix=/app/apache --enable-rewrite --enable-so --enable-deflate --enable-expires --enable-headers
cd /tmp/pcre-8.31
./configure --prefix=/app/local --enable-jit --enable-utf8
${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/httpd-2.4.3
./configure --prefix=/app/apache --enable-rewrite --enable-so --enable-deflate --enable-expires --enable-headers --enable-proxy-fcgi --with-mpm=event --with-included-apr --with-pcre=/app/local
${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/php-5.3.17
./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-gd --with-curl=/usr/lib --with-config-file-path=/app/php --enable-soap=shared --with-openssl --enable-mbstring --with-mhash --enable-mysqlnd --with-pear --with-mysqli=mysqlnd --disable-cgi --with-jpeg-dir --with-png-dir --with-mcrypt=/app/local --enable-static
cd /tmp
git clone git://github.com/ByteInternet/libapache-mod-fastcgi.git
cd /tmp/libapache-mod-fastcgi/
patch -p1 < debian/patches/byte-compile-against-apache24.diff
sed -e "s%/usr/local/apache2%/app/apache%" Makefile.AP2 > Makefile
${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/php-5.4.8
./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-gd --with-curl=/usr/lib --with-config-file-path=/app/php --enable-soap=shared --with-openssl --enable-mbstring --with-mhash --enable-mysqlnd --with-pear --with-mysqli=mysqlnd --with-jpeg-dir --with-png-dir --with-mcrypt=/app/local --enable-static --enable-fpm --with-pcre-dir=/app/local
${MAKE_CMD} && ${MAKE_CMD} install

/app/php/bin/pear config-set php_dir /app/php
/app/php/bin/pecl install igbinary
echo " " | /app/php/bin/pecl install memcache
echo " " | /app/php/bin/pecl install apc
echo " " | /app/php/bin/pecl install apc-3.1.13
/app/php/bin/pecl install igbinary

# cd /tmp/cyrus-sasl-2.1.25
# ./configure --prefix=/app/local
# ${MAKE_CMD} && ${MAKE_CMD} install
# export SASL_PATH=/app/local/lib/sasl2

cd /tmp/libmemcached-1.0.11
cd /tmp/libmemcached-1.0.13
./configure --prefix=/app/local
# the configure script detects sasl, but is still foobar'ed
# sed -i 's/LIBMEMCACHED_WITH_SASL_SUPPORT 0/LIBMEMCACHED_WITH_SASL_SUPPORT 1/' Makefile
${MAKE_CMD} && ${MAKE_CMD} install

# for libmemcached 1.0.4
# LDFLAGS=-L/app/local/lib ./configure --prefix=/app/local --with-libsasl2-prefix=/usr

cd /tmp/memcached-2.1.0
/app/php/bin/phpize
./configure --with-libmemcached-dir=/app/local \
Expand All @@ -85,8 +113,8 @@ cd /tmp/memcached-2.1.0
--enable-static
${MAKE_CMD} && ${MAKE_CMD} install

echo '2.2.23' > /app/apache/VERSION
echo '5.3.17' > /app/php/VERSION
echo '2.4.3' > /app/apache/VERSION
echo '5.4.8' > /app/php/VERSION
mkdir /tmp/build
mkdir /tmp/build/local
mkdir /tmp/build/local/lib
Expand All @@ -97,6 +125,7 @@ cp -a /app/php /tmp/build/
# cp -aL /app/local/lib/libhashkit.so.2 /tmp/build/local/lib/
cp -aL /app/local/lib/libmcrypt.so.4 /tmp/build/local/lib/
cp -aL /app/local/lib/libmemcached.so.11 /tmp/build/local/lib/
cp -aL /app/local/lib/libpcre.so.1 /tmp/build/local/lib/
# cp -aL /app/local/lib/libmemcachedprotocol.so.0 /tmp/build/local/lib/
# cp -aL /app/local/lib/libmemcachedutil.so.2 /tmp/build/local/lib/
# cp -aL /app/local/lib/sasl2/*.so.2 /tmp/build/local/lib/sasl2/
Expand Down
Loading

0 comments on commit a496bbf

Please sign in to comment.