Skip to content

Commit

Permalink
improved build w/ vulcan, stripped sasl, postgres support from php an…
Browse files Browse the repository at this point in the history
…d smaller binaries, changing the serverlimit back to 8 clients, moving the src s3 to git, log request time to serve
  • Loading branch information
wing.lian@gmail.com authored and wing.lian@gmail.com committed Aug 27, 2012
1 parent a429092 commit 7e5e956
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 91 deletions.
83 changes: 4 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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
Expand All @@ -15,82 +15,8 @@ The config files are bundled with the LP itself:
Pre-compiling binaries
----------------------

# use AMI ami-5c9b4935
apt-get -y update && apt-get -y install g++ gcc libssl-dev libpng-dev libxml2-dev libmysqlclient-dev libpq-dev libpcre3-dev php5-dev php-pear curl libcurl3 libcurl3-dev php5-curl libsasl2-dev libmcrypt-dev

#download all the srcs
curl -L http://www.apache.org/dist/httpd/httpd-2.2.22.tar.gz -o /tmp/httpd-2.2.22.tar.gz
curl -L http://us.php.net/get/php-5.3.10.tar.gz/from/us2.php.net/mirror -o /tmp/php-5.3.10.tar.gz
curl -L https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz -o /tmp/libmemcached-1.0.4.tar.gz
curl -L http://pecl.php.net/get/memcached-2.0.1.tgz -o /tmp/memcached-2.0.1.tgz

#untar all the srcs
tar -C /tmp -xzvf /tmp/httpd-2.2.22.tar.gz
tar -C /tmp -xzvf /tmp/php-5.3.10.tar.gz
tar -C /tmp -xzvf /tmp/libmemcached-1.0.4.tar.gz
tar -C /tmp -xzvf /tmp/memcached-2.0.1.tgz

#make the directories
mkdir /app
mkdir /app/{apache,php,local}
mkdir /app/php/ext
mkdir /app/local/{lib,bin}

#copy libs
cp -a /usr/lib/libmcrypt* /app/local/lib/
cp -a /usr/lib/libmysqlclient* /app/local/lib/
cp -a /usr/lib/libsasl2* /app/local/lib/

cp -a /usr/bin/mysql_config /app/local/bin/

export CFLAGS='-g0 -O2'
export CXXFLAGS="${CFLAGS}"

# apache
cd /tmp/httpd-2.2.22
./configure --prefix=/app/apache --enable-rewrite --enable-so --enable-deflate --enable-expires --enable-headers
make && make install

# php
cd /tmp/php-5.3.10
./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-pgsql --with-pdo-pgsql --with-iconv --with-gd --with-curl=/usr/lib --with-config-file-path=/app/php --enable-soap=shared --with-openssl --enable-mbstring --with-mhash --enable-pcntl --enable-mysqlnd --with-pear --with-mysqli=mysqlnd
make && make install

# libmemcached
cd /tmp/libmemcached-1.0.4
./configure --prefix=/app/local
make && make install

/app/php/bin/pear config-set php_dir /app/php
/app/php/bin/pecl install memcache
/app/php/bin/pecl install apc

# pecl memcached
cd /tmp/memcached-2.0.1
# edit config.m4 line 21 so no => yes ############### IMPORTANT!!! ###############
sed -i -e '21 s/no, no/yes, yes/' /tmp/memcached-2.0.1/config.m4
/app/php/bin/phpize
./configure --with-libmemcached-dir=/app/local/ --prefix=/app/php --with-php-config=/app/php/bin/php-config
make && make install

# make it a little leaner
rm -rf /app/apache/manual/

cp /app/local/lib/libsasl2.so.2 /app/php/ext/
cp /usr/lib/libmcrypt.so.4 /app/php/ext/
cp /usr/lib/libmysqlclient.so.16 /app/php/ext/
cp /app/local/lib/libmemcachedutil.so.2 /app/php/ext/
cp /app/local/lib/libmemcached.so.9 /app/php/ext/
cp /app/local/lib/libmemcachedprotocol.so.0 /app/php/ext/
cp /app/local/lib/libhashkit.so.1 /app/php/ext/

# package
cd /app
echo '2.2.22' > apache/VERSION
tar -cv apache | gzip -c9 > apache-2.2.22.tar.gz
echo '5.3.10' > php/VERSION
tar -cv php | gzip -c9 > php-5.3.10.tar.gz

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

Hacking
-------
Expand All @@ -101,5 +27,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
14 changes: 6 additions & 8 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ if [ -f www/Procfile ]; then
mv www/Procfile .
fi

APACHE_URL="https://s3.amazonaws.com/heroku-buildpack-binaries/apache-$APACHE_VERSION.tar.gz"
echo "-----> Bundling Apache version $APACHE_VERSION"
curl --silent --max-time 60 --location "$APACHE_URL" | tar xz

PHP_URL="https://s3.amazonaws.com/heroku-buildpack-binaries/php-$PHP_VERSION.tar.gz"
echo "-----> Bundling PHP version $PHP_VERSION"
curl --silent --max-time 60 --location "$PHP_URL" | tar xz
echo "-----> Bundling Apache $APACHE_VERSION/PHP $PHP_VERSION build"
tar xzf $LP_DIR/src/build.tgz

# update config files
cp $LP_DIR/conf/httpd.conf $APACHE_PATH/conf
Expand All @@ -57,14 +52,17 @@ 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
tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
export LD_LIBRARY_PATH=/app/php/ext
export LD_LIBRARY_PATH=/app/local/lib
export PHP_INI_SCAN_DIR=/app/www
# let's check for hook scripts
Expand Down
75 changes: 75 additions & 0 deletions build/vulcan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash
set -e

mkdir /app/local
mkdir /app/local/lib
mkdir /app/local/bin
mkdir /app/apache
mkdir /app/php
mkdir /app/php/ext

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.10/+download/libmemcached-1.0.10.tar.gz -o /tmp/libmemcached-1.0.10.tar.gz
curl -L http://www.apache.org/dist/httpd/httpd-2.2.22.tar.gz -o /tmp/httpd-2.2.22.tar.gz
curl -L http://us.php.net/get/php-5.3.16.tar.gz/from/us2.php.net/mirror -o /tmp/php-5.3.16.tar.gz
curl -L http://pecl.php.net/get/memcached-2.1.0.tgz -o /tmp/memcached-2.1.0.tgz

tar -C /tmp -xzvf /tmp/libmcrypt-2.5.7.tar.gz
tar -C /tmp -xzvf /tmp/cyrus-sasl-2.1.25.tar.gz
tar -C /tmp -xzvf /tmp/libmemcached-1.0.10.tar.gz
tar -C /tmp -xzvf /tmp/httpd-2.2.22.tar.gz
tar -C /tmp -xzvf /tmp/php-5.3.16.tar.gz
tar -C /tmp -xzvf /tmp/memcached-2.1.0.tgz

export CFLAGS='-g0 -O2 -s'
export CXXFLAGS="${CFLAGS}"

MAKE_CMD=`which make`

cd /tmp/libmcrypt-2.5.7
./configure --prefix=/app/local
${MAKE_CMD} && ${MAKE_CMD} install

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

cd /tmp/libmemcached-1.0.10
./configure --prefix=/app/local
${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/httpd-2.2.22
./configure --prefix=/app/apache --enable-rewrite --enable-so --enable-deflate --enable-expires --enable-headers
${MAKE_CMD} && ${MAKE_CMD} install

cd /tmp/php-5.3.16
./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 --enable-static
${MAKE_CMD} && ${MAKE_CMD} install

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

cd /tmp/memcached-2.1.0
/app/php/bin/phpize
#SASL supports still doesn't work
./configure --with-libmemcached-dir=/app/local/ --prefix=/app/php --with-php-config=/app/php/bin/php-config
${MAKE_CMD} && ${MAKE_CMD} install

echo '2.2.22' > /app/apache/VERSION
echo '5.3.16' > /app/php/VERSION
mkdir /tmp/build
mkdir /tmp/build/local
mkdir /tmp/build/local/lib
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/

rm -rf /tmp/build/apache/manual/

4 changes: 2 additions & 2 deletions conf/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
4 changes: 2 additions & 2 deletions conf/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1906,9 +1906,9 @@ extension=apc.so
apc.stat=0

[memcache]
;extension=memcache.so
; extension=memcache.so

[memcached]
extension=memcached.so
memcached.use_sasl = 1
; memcached.use_sasl = 1

Binary file added src/build.tgz
Binary file not shown.

0 comments on commit 7e5e956

Please sign in to comment.