Skip to content

Commit

Permalink
Update binary vendoring steps in README
Browse files Browse the repository at this point in the history
For Apache 2.2.25 and PHP 5.3.27.

As of now, the vendoring can now be done in a blank dyno rather
easily.  This process is now explained explicitly in the README.

The following is an overview of some of the changes:

* Rewrite recipes into bash-script form

* Make re-entrant (via clearing /app) for easier iteration

* Use variable substitutions for version, directory, and archive names
  instead of repeating chunks of each all over the place.

* Make downloading optional, again to assist iteration.

* Silence GNU Make steps via '-s' to quiet down builds (warnings are
  still shown).

* Rely on the bash-ism pushd and popd to be more robust to slight
  changes in relative paths that may occur in the future.

* Rely on the PHP-distributed version of PEAR/PECL rather than the
  apt-get install version, which has a more dubious set of default
  paths and can't be done in-dyno.  This makes the steps for dealing
  with 'APC' much simpler.

* Use default responses for prompts when building APC rather than
  prompting the builder.

* Sanitize cgi-bin of default Apache programs.

* Create binary-vendoring tarballs with the same name that they are
  intended to be uploaded as.

  Notably, name of the tarball and the directory contained within that
  tarball will not match because the contained directory is devoid of
  version numbering, unlike the name of the tarball.
  • Loading branch information
fdr authored and Daniel Farina committed Jul 30, 2013
1 parent 8778195 commit 062fb12
Showing 1 changed file with 88 additions and 40 deletions.
128 changes: 88 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,93 @@ The config files are bundled with the build pack itself:
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
In a Heroku Dyno, one can run the following as executable text. After
running it, `/app` will contain, among other entities,
`apache-2.2.25.tar.gz` and `php-5.3.27.tar.gz`, which should be
uploaded to a location that can be downloaded by the build pack (see
the URIs in `compile`).

#!/bin/bash
set -uex
cd /tmp

# Clear /app directory
find /app -mindepth 1 -print0 | xargs -0 rm -rf

# Take care of vendoring Apache.
httpd_version=2.2.25
httpd_dirname=httpd-$httpd_version
httpd_archive_name=$httpd_dirname.tar.bz2

# Download Apache if necessary.
if [ ! -f $httpd_archive_name ]
then
curl -LO ftp://ftp.osuosl.org/pub/apache//httpd/$httpd_archive_name
fi

# Clean and extract Apache.
rm -rf $httpd_dirname
tar jxf $httpd_archive_name

# Build and install Apache.
pushd $httpd_dirname
./configure --prefix=/app/apache --enable-rewrite --with-included-apr
make -s
make install -s
popd

# Take care of vendoring PHP.
php_version=5.3.27
php_dirname=php-$php_version
php_archive_name=$php_dirname.tar.bz2

# Download PHP if necessary.
if [ ! -f $php_archive_name ]
then
curl -Lo $php_archive_name http://us1.php.net/get/php-5.3.27.tar.bz2/from/www.php.net/mirror
fi

# Clean and extract PHP.
rm -rf $php_dirname
tar jxf $php_archive_name

# Compile PHP
pushd $php_dirname
./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 -s
make install -s
popd

# Copy in MySQL client library.
mkdir -p /app/php/lib/php
cp /usr/lib/libmysqlclient.so.16 /app/php/lib/php

# 'apc' installation
#
# $PATH manipulation Necessary for 'pecl install', which relies on
# PHP binaries relative to $PATH.

export PATH=/app/php/bin:$PATH
/app/php/bin/pecl channel-update pecl.php.net

# Use defaults for apc build prompts.
yes '' | /app/php/bin/pecl install apc

# Sanitize default cgi-bin to rid oneself of Apache sample
# programs.
find /app/apache/cgi-bin/ -mindepth 1 -print0 | xargs -0 rm -r

# Stamp and archive binaries.
pushd /app
echo $httpd_version > apache/VERSION
tar -zcf apache-$httpd_version.tar.gz apache
echo $php_version > php/VERSION
tar -zcf php-$php_version.tar.gz php
popd


Hacking
Expand All @@ -66,4 +114,4 @@ Meta
----

Created by Pedro Belo.
Many thanks to Keith Rarick for the help with assorted Unix topics :)
Many thanks to Keith Rarick for the help with assorted Unix topics :)

0 comments on commit 062fb12

Please sign in to comment.