Skip to content

Loading…

minor enhancements #8

Closed
wants to merge 13 commits into from

4 participants

@winglian

Added apache mod_deflate, mod_expires, mod_headers
Added PECL Memcached module with SASL support
Use GZIP -9 compression for tarball
Set ServerSignature, ServerTokens, and HostnameLookups to appropriate values
Added built-in PEAR in include_path
Set apc.stat = 0 since files can't change between service restarts
Added user definable hook scripts that are executed right before apache service starts
Added WWWROOT config variable support so document root doesn't have to be the top directory
PHP uses mysqlnd instead of libmysqlclient

The compiled slug is about 14MB, which is larger than HEAD, but is to be expected with the extra libraries needed. Can probably reduce the slug size another 1MB or so by removing the libmysqlclient.so.16 since it is replaced by mysqlnd.

winglian added some commits
@winglian winglian Added apache mod_deflate, mod_expires, mod_headers
Added PECL Memcached module with SASL support
Use GZIP -9 compression for tarball
Set ServerSignature, ServerTokens, and HostnameLookups to appropriate values
Added built-in PEAR in include_path
Set apc.stat = 0 since files can't change between service restarts
Added user definable hook scripts that are executed right before apache service starts
Added WWWROOT config variable support so document root doesn't have to be the top directory
4b99be5
@winglian winglian set a slug id so each dyno knows it came from the same slug/commit 817e28d
@winglian winglian bug in php location 92b9d9c
@winglian winglian wrong path when in slug creation env 6e96c69
@winglian winglian wrong path when in slug creation env da836a4
@winglian winglian added some output for slug id when compiling slug 2283a3b
@winglian winglian load hooks with source rather than /bin/bash e32a0bb
@winglian winglian reverting last commit 7e7643e
@winglian winglian better logging needed a5da51f
@winglian winglian log request time to serve a429092
@yandod

Awesome improvement. :+1:

@winglian

I've updated this buildpack to build the binaries with vulcan and store them within the repo itself since things get confusing when having to reference S3

winglian added some commits
@winglian winglian improved build w/ vulcan, stripped sasl, postgres support from php an…
…d smaller binaries, changing the serverlimit back to 8 clients, log request time to serve

added jpeg and PNG support for GD. bsdiff so releases can simply be patched against the base buildpack binary,
mcrypt support, missing libmemcached.so.11
657ca54
@winglian winglian improved PHP error log output to heroku syslog a79bbf2
@winglian winglian README.md 197366e
@sumkincpp sumkincpp referenced this pull request in sumkincpp/heroku-buildpack-symfony2
@iphoting iphoting Newrelic version: 3.1.5.137.
Fixed: #8.
014eba2
@sumkincpp sumkincpp referenced this pull request in sumkincpp/heroku-buildpack-symfony2
@iphoting iphoting Newrelic version: 3.2.5.143.
See #8.
50fc89e
@azr azr referenced this pull request in azr/heroku-buildpack-symfony2
@iphoting iphoting Newrelic version: 3.2.5.147.
Closes #8.
6d14c8f
@hinaloe hinaloe pushed a commit to hinaloe/heroku-buildpack-php that referenced this pull request
@iphoting iphoting Newrelic version: 3.7.5.7.
Closes #8.
d26d774
@dzuelke

Thanks :) I guess this is obsolete now ;)

@dzuelke dzuelke closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2012
  1. @winglian

    Added apache mod_deflate, mod_expires, mod_headers

    winglian committed
    Added PECL Memcached module with SASL support
    Use GZIP -9 compression for tarball
    Set ServerSignature, ServerTokens, and HostnameLookups to appropriate values
    Added built-in PEAR in include_path
    Set apc.stat = 0 since files can't change between service restarts
    Added user definable hook scripts that are executed right before apache service starts
    Added WWWROOT config variable support so document root doesn't have to be the top directory
Commits on Apr 24, 2012
  1. @winglian
  2. @winglian

    bug in php location

    winglian committed
  3. @winglian
  4. @winglian
Commits on Apr 25, 2012
  1. @winglian
Commits on Apr 26, 2012
  1. @winglian
  2. @winglian

    reverting last commit

    winglian committed
Commits on Apr 28, 2012
  1. @winglian

    better logging needed

    winglian committed
Commits on May 10, 2012
  1. @winglian

    log request time to serve

    winglian committed
Commits on Sep 29, 2012
  1. @winglian

    improved build w/ vulcan, stripped sasl, postgres support from php an…

    winglian committed
    …d smaller binaries, changing the serverlimit back to 8 clients, log request time to serve
    
    added jpeg and PNG support for GD. bsdiff so releases can simply be patched against the base buildpack binary,
    mcrypt support, missing libmemcached.so.11
Commits on Dec 10, 2012
  1. @winglian
  2. @winglian

    README.md

    winglian committed
Showing with 202 additions and 57 deletions.
  1. +7 −43 README.md
  2. +43 −9 bin/compile
  3. +13 −0 build/bsdiff.sh
  4. +105 −0 build/vulcan.sh
  5. +8 −4 conf/httpd.conf
  6. +26 −1 conf/php.ini
  7. BIN src/bsdiff.tgz
View
50 README.md
@@ -6,55 +6,20 @@ This is a build pack bundling PHP and Apache for Heroku apps.
Configuration
-------------
-The config files are bundled with the LP itself:
+The config files are bundled with the buildpack itself:
* conf/httpd.conf
* conf/php.ini
+Configure Heroku to use this buildpack repo AND branch. If you do not specify the branch, you will have unexpected results.
+
+ heroku config:set BUILDPACK_URL=git://github.com/winglian/heroku-buildpack-php.git#master
Pre-compiling binaries
----------------------
- # apache
- mkdir /app
- wget http://apache.cyberuse.com//httpd/httpd-2.2.19.tar.gz
- tar xvzf httpd-2.2.19.tar.gz
- cd httpd-2.2.19
- ./configure --prefix=/app/apache --enable-rewrite
- make
- make install
- cd ..
-
- # php
- wget http://us2.php.net/get/php-5.3.6.tar.gz/from/us.php.net/mirror
- mv mirror php.tar.gz
- tar xzvf php.tar.gz
- cd php-5.3.6/
- ./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-mysql --with-pdo-mysql --with-pgsql --with-pdo-pgsql --with-iconv --with-gd --with-curl=/usr/lib --with-config-file-path=/app/php --enable-soap=shared --with-openssl
- make
- make install
- cd ..
-
- # php extensions
- mkdir /app/php/ext
- cp /usr/lib/libmysqlclient.so.15 /app/php/ext/
-
- # pear
- apt-get install php5-dev php-pear
- pear config-set php_dir /app/php
- pecl install apc
- mkdir /app/php/include/php/ext/apc
- cp /usr/lib/php5/20060613/apc.so /app/php/ext/
- cp /usr/include/php5/ext/apc/apc_serializer.h /app/php/include/php/ext/apc/
-
-
- # package
- cd /app
- echo '2.2.19' > apache/VERSION
- tar -zcvf apache.tar.gz apache
- echo '5.3.6' > php/VERSION
- tar -zcvf php.tar.gz php
-
+ vulcan build -v -s ./build -p /tmp/build -c "./vulcan.sh"
+ cp /tmp/build.tgz src/build.tgz
Hacking
-------
@@ -65,5 +30,4 @@ To change this buildpack, fork it on Github. Push up changes to your fork, then
Meta
----
-Created by Pedro Belo.
-Many thanks to Keith Rarick for the help with assorted Unix topics :)
+Original buildpack by Pedro Belo. https://github.com/heroku/heroku-buildpack-php
View
52 bin/compile
@@ -5,10 +5,12 @@
set -e
# config
-APACHE_VERSION="2.2.22"
+APACHE_VERSION="2.2.23"
APACHE_PATH="apache"
-PHP_VERSION="5.3.10"
+PHP_VERSION="5.3.17"
PHP_PATH="php"
+BUILDPACK_VERSION="1.2"
+
BIN_DIR=$(dirname $0)
BUILD_DIR=$1
@@ -30,13 +32,16 @@ if [ -f www/Procfile ]; then
mv www/Procfile .
fi
-APACHE_URL="https://s3.amazonaws.com/php-lp/apache-$APACHE_VERSION.tar.gz"
-echo "-----> Bundling Apache version $APACHE_VERSION"
-curl --silent --max-time 60 --location "$APACHE_URL" | tar xz
+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
-PHP_URL="https://s3.amazonaws.com/php-lp/php-$PHP_VERSION.tar.gz"
-echo "-----> Bundling PHP version $PHP_VERSION"
-curl --silent --max-time 60 --location "$PHP_URL" | tar xz
+# echo "-----> Extracting bsdiff binary"
+# tar xzf $LP_DIR/src/bsdiff.tgz
+# echo "-----> Bundling Apache $APACHE_VERSION/PHP $PHP_VERSION build"
+# gunzip $LP_DIR/src/build.tgz
+# local/bin/bspatch $LP_DIR/src/build.tar $LP_DIR/src/build-apache-$APACHE_VERSION-php-$PHP_VERSION.tar $LP_DIR/src/build.bsdiff
+# tar xf $LP_DIR/src/build-apache-$APACHE_VERSION-php-$PHP_VERSION.tar
# update config files
cp $LP_DIR/conf/httpd.conf $APACHE_PATH/conf
@@ -46,16 +51,45 @@ cp $LP_DIR/conf/php.ini php
mkdir -p bin
ln -s /app/php/bin/php bin/php
+export LD_LIBRARY_PATH=$BUILD_DIR/local/lib
+
+# set a slug_id identifier
+slug_id=$(php/bin/php -r "echo md5(uniqid('', TRUE));")
+echo $slug_id > SLUG_ID
+echo "Creating Slug Identifier file with id: ${slug_id}"
+
cat >>boot.sh <<EOF
+echo "Checking for WWWROOT environment variable..."
+if [ -n "\${WWWROOT:+x}" ]; then
+ sed -ie "s%/app/www%/app/www\$WWWROOT%" /app/apache/conf/httpd.conf
+fi
+
+export HW_ADDR=\`/sbin/ifconfig eth0 | grep HWaddr | awk '{print \$5}'\`
+echo "SetEnv HW_ADDR \$HW_ADDR" >> /app/apache/conf/httpd.conf;
+
for var in \`env|cut -f1 -d=\`; do
echo "PassEnv \$var" >> /app/apache/conf/httpd.conf;
done
touch /app/apache/logs/error_log
touch /app/apache/logs/access_log
+export PHP_ERROR_LOG=\`/app/php/bin/php -i | grep error_log | awk '{print \$5}'\`
+touch \$PHP_ERROR_LOG
+chmod 0777 \$PHP_ERROR_LOG
tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
-export LD_LIBRARY_PATH=/app/php/ext
+tail -F \$PHP_ERROR_LOG &
+export LD_LIBRARY_PATH=/app/local/lib
export PHP_INI_SCAN_DIR=/app/www
+
+# let's check for hook scripts
+if [ -d www/.hooks ]; then
+ for file in www/.hooks/*.sh; do
+ if [ -f \$file ]; then
+ /bin/bash \$file
+ fi
+ done
+fi
+
echo "Launching apache"
exec /app/apache/bin/httpd -DNO_DETACH
EOF
View
13 build/bsdiff.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+cd /tmp
+curl -O curl -O http://www.daemonology.net/bsdiff/bsdiff-4.3.tar.gz
+tar -xzf bsdiff-4.3.tar.gz
+cd bsdiff-4.3
+sed -i '13 s/^/#/' Makefile
+sed -i '14 s/^/#/' Makefile
+sed -i '15 s/^/#/' Makefile
+make
+mkdir -p /tmp/build/local/bin
+cp bsdiff /tmp/build/local/bin
+cp bspatch /tmp/build/local/bin
View
105 build/vulcan.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+set -e
+
+mkdir /app/local
+mkdir /app/local/lib
+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
+ls -tr *.deb > packages.txt
+while read l; do
+ ar x $l
+ tar -xzf data.tar.gz
+ rm data.tar.gz
+done < packages.txt
+
+cp -a /tmp/usr/include/* /app/local/include
+cp -a /tmp/usr/lib/* /app/local/lib
+
+# 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
+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/memcached-2.1.0.tgz
+
+export CFLAGS='-g0 -O2 -s -m64 -march=core2 -mtune=generic -pipe '
+export CXXFLAGS="${CFLAGS}"
+export CPPFLAGS="-I/app/local/include"
+export LD_LIBRARY_PATH="/app/local/lib"
+export MAKEFLAGS="-j5"
+export MAKE_CMD="/usr/bin/make $MAKEFLAGS"
+
+# cd /tmp/libmcrypt-2.5.7
+# ./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
+${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
+${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
+
+# 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
+./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 \
+ --prefix=/app/php \
+ --enable-memcached-igbinary \
+ --enable-memcached-json \
+ --with-php-config=/app/php/bin/php-config \
+ --enable-static
+${MAKE_CMD} && ${MAKE_CMD} install
+
+echo '2.2.23' > /app/apache/VERSION
+echo '5.3.17' > /app/php/VERSION
+mkdir /tmp/build
+mkdir /tmp/build/local
+mkdir /tmp/build/local/lib
+mkdir /tmp/build/local/lib/sasl2
+cp -a /app/apache /tmp/build/
+cp -a /app/php /tmp/build/
+# cp -aL /usr/lib/libmysqlclient.so.16 /tmp/build/local/lib/
+# 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/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/
+
+rm -rf /tmp/build/apache/manual/
+
View
12 conf/httpd.conf
@@ -39,8 +39,8 @@ ServerRoot "/app/apache/"
#Listen 12.34.56.78:80
Listen ${PORT}
-ServerLimit 1
-MaxClients 1
+ServerLimit 8
+MaxClients 8
ListenBackLog 1024
#
@@ -101,6 +101,10 @@ ServerAdmin you@example.com
#
ServerName 127.0.0.1
+ServerSignature Off
+ServerTokens Prod
+HostnameLookups Off
+
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
@@ -206,7 +210,7 @@ LogLevel warn
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
- LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+ LogFormat "%h %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
@@ -221,7 +225,7 @@ LogLevel warn
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
- CustomLog "logs/access_log" common
+ CustomLog "logs/access_log" combined
#
# If you prefer a logfile with access, agent, and referer information
View
27 conf/php.ini
@@ -636,6 +636,7 @@ html_errors = Off
;error_log = php_errors.log
; Log errors to syslog (Event Log on NT, not valid in Windows 95).
;error_log = syslog
+error_log = "/app/php/var/log/error_log"
;;;;;;;;;;;;;;;;;
; Data Handling ;
@@ -782,6 +783,7 @@ default_mimetype = "text/html"
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
+include_path = ".:/app/php/lib/php"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
@@ -945,7 +947,6 @@ default_socket_timeout = 60
; Be sure to appropriately set the extension_dir directive.
;
extension=soap.so
-extension=apc.so
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_fileinfo.dll
@@ -1900,3 +1901,27 @@ ldap.max_links = -1
; Local Variables:
; tab-width: 4
; End:
+
+[apc]
+extension=apc.so
+apc.stat=0
+
+[memcache]
+; extension=memcache.so
+
+[memcached]
+extension=memcached.so
+memcached.use_sasl = 1
+
+[igbinary]
+extension=igbinary.so
+; Use igbinary as session serializer
+session.serialize_handler=igbinary
+
+; Enable or disable compacting of duplicate strings
+; The default is On.
+igbinary.compact_strings=On
+
+; Use igbinary as serializer in APC cache (3.1.7 or later)
+; apc.serializer=igbinary
+
View
BIN src/bsdiff.tgz
Binary file not shown.
Something went wrong with that request. Please try again.