Skip to content

Instantly share code, notes, and snippets.

@pateketrueke
Last active October 7, 2015 10:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pateketrueke/3152679 to your computer and use it in GitHub Desktop.
Save pateketrueke/3152679 to your computer and use it in GitHub Desktop.
Apache 2.2.24 & PHP 5.4.14 / Heroku pre-compile script
mkdir -p /app
# Prepare the filesystem
mkdir -p /tmp/build
cd /tmp/build
# Compiling Apache
curl http://www.us.apache.org/dist/httpd/httpd-2.2.24.tar.gz | tar xzf -
cd httpd-2.2.24
./configure --prefix=/app/apache --with-z=/usr/local/zlib --enable-rewrite --enable-so --enable-deflate --enable-expires --enable-headers
make && make install
cd ..
# Apache libraries
mkdir -p /app/php/ext
cp /app/apache/lib/libapr-1.so /app/php/ext
cp /app/apache/lib/libaprutil-1.so /app/php/ext
cp /app/apache/lib/libapr-1.so.0 /app/php/ext
cp /app/apache/lib/libaprutil-1.so.0 /app/php/ext
# Compiling PHP
curl -L http://php.net/get/php-5.4.16.tar.gz/from/us1.php.net/mirror | tar xzf -
cd php-5.4.16
./configure --prefix=/app/php --with-apxs2=/app/apache/bin/apxs --with-pgsql --with-pdo-pgsql --with-iconv --with-config-file-path=/app/php --with-openssl --with-readline --enable-mbstring --with-gd --with-jpeg-dir=/usr --with-curl=/usr --enable-zip --with-pcre-regex --with-zlib
make && make install
cd ..
# PHP Extensions
cp php-5.4.16/libs/libphp5.so /app/apache/modules/
# APC
curl http://pecl.php.net/get/APC/3.1.13 | tar xzf -
cd APC-3.1.13
/app/php/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/app/php/bin/php-config
make && make install
cd ..
# MongoDB
curl http://pecl.php.net/get/mongo/1.3.7 | tar xzf -
cd mongo-1.3.7
/app/php/bin/phpize
./configure --with-php-config=/app/php/bin/php-config
make && make install
cd ..
mv /app/php/lib/php/extensions/no-debug-non-zts-20100525/*.so /app/php/ext/
rm -rf /app/php/lib/php/extensions
# Create packages
cd /app
echo '2.2.24' > apache/VERSION
tar -zcvf apache.tar.gz apache
echo '5.4.16' > php/VERSION
tar -zcvf php.tar.gz php
# Upload to your server using SCP
# scp '-P 22' apache.tar.gz root@domain.tld:/path/to
# scp '-P 22' php.tar.gz root@domain.tld:/path/to
@BaylorRae
Copy link

I'm sorry if this is a dumb question, but how do you use this with Heroku?

@Hengjie
Copy link

Hengjie commented Nov 9, 2012

You could compile it using Ubuntu 10.04 and then push the /app repository into Heroku or you could use this as a script to be run in Heroku itself in the Procfile.

e.g. It would say something like: "web: sh thisScript.sh" without the quotes, where thisScript.sh is exactly that. The only issue with that is that I believe compiling takes time and the running of thisScript.sh has a timeout of 60 seconds on Heroku.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment