Skip to content

Commit

Permalink
Added apache mod_deflate, mod_expires, mod_headers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
winglian committed Apr 2, 2012
1 parent f902738 commit 4b99be5
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 34 deletions.
98 changes: 67 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,81 @@ The config files are bundled with the LP itself:
Pre-compiling binaries
----------------------

# apache
# 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
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 ..
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
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 ..
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

# php extensions
mkdir /app/php/ext
cp /usr/lib/libmysqlclient.so.15 /app/php/ext/
# libmemcached
cd /tmp/libmemcached-1.0.4
./configure --prefix=/app/local
make && make install

# 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/
/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.19' > apache/VERSION
tar -zcvf apache.tar.gz apache
echo '5.3.6' > php/VERSION
tar -zcvf php.tar.gz php
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


Hacking
Expand All @@ -66,4 +102,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 :)
19 changes: 17 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ if [ -f www/Procfile ]; then
mv www/Procfile .
fi

APACHE_URL="https://s3.amazonaws.com/php-lp/apache-$APACHE_VERSION.tar.gz"
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/php-lp/php-$PHP_VERSION.tar.gz"
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

Expand All @@ -47,6 +47,11 @@ mkdir -p bin
ln -s /app/php/bin/php bin/php

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
for var in \`env|cut -f1 -d=\`; do
echo "PassEnv \$var" >> /app/apache/conf/httpd.conf;
done
Expand All @@ -56,6 +61,16 @@ tail -F /app/apache/logs/error_log &
tail -F /app/apache/logs/access_log &
export LD_LIBRARY_PATH=/app/php/ext
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
Expand Down
4 changes: 4 additions & 0 deletions conf/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion conf/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,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"
Expand Down Expand Up @@ -945,7 +946,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
Expand Down Expand Up @@ -1900,3 +1900,15 @@ 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

0 comments on commit 4b99be5

Please sign in to comment.