Skip to content

Instantly share code, notes, and snippets.

@napkindrawing
Created March 26, 2013 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napkindrawing/5248230 to your computer and use it in GitHub Desktop.
Save napkindrawing/5248230 to your computer and use it in GitHub Desktop.
#!/bin/bash
APP_NAME="nginx"
APP_VER="1.2.7"
APP_SRC="http://nginx.org/download/nginx-${APP_VER}.tar.gz"
APP_CKSUM="d252f5c689a14a668e241c744ccf5f06"
CH_TMP="/tmp/ch_install"
APP_COMPILE_ROOT="$CH_TMP/${APP_NAME}-$APP_VER"
APP_PREFIX="/usr/local/${APP_NAME}-${APP_VER}"
APP_ARCH="$CH_TMP/${APP_NAME}-$APP_VER.tar.gz"
MODULES_ROOT="$CH_TMP/nginx-modules"
##SOURCE ngx_devel_kit https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz
##SOURCE headers_more_nginx_module https://github.com/agentzh/headers-more-nginx-module/archive/v0.19rc1.tar.gz
##SOURCE echo_nginx_module https://github.com/agentzh/echo-nginx-module/archive/v0.44.tar.gz
##SOURCE lua_nginx_module https://github.com/chaoslawful/lua-nginx-module/archive/v0.7.18.tar.gz
##SOURCE nginx_upload_progress_module https://github.com/masterzen/nginx-upload-progress-module/archive/v0.9.0.tar.gz
##SOURCE set_misc_nginx_module https://github.com/agentzh/set-misc-nginx-module/archive/v0.22rc8.tar.gz
##SOURCE nginx_log_if https://github.com/cfsego/ngx_log_if/archive/4e22ea0ce8e80ed0adb09b02260c41208634f419.tar.gz
if [ ! -d $CH_TMP ]; then
echo "Creating install directory: $CH_TMP";
mkdir $CH_TMP
fi
cd "$CH_TMP"
if [ ! -f "$APP_ARCH" ]; then
echo "Downloading ${APP_NAME} $APP_VER: $APP_SRC"
wget -q -O "$APP_ARCH" "$APP_SRC"
else
echo "Detected existing archive for ${APP_NAME} $APP_VER: $APP_ARCH"
fi
APP_FOUND_CKSUM=`md5sum $APP_ARCH | cut -d' ' -f1`
if [ "$APP_CKSUM" != "$APP_FOUND_CKSUM" ]; then
echo "Downloaded ${APP_NAME} $APP_ARCH has invalid checksum, expected $APP_CKSUM found $APP_FOUND_CKSUM"
exit 1
fi
if [ -d "$APP_COMPILE_ROOT" ]; then
echo "${APP_NAME} archive already extracted"
else
echo "Extracting ${APP_NAME}"
tar -xzf "$APP_ARCH"
fi
if [ ! -d $MODULES_ROOT ]; then
echo "Creating modules directory: $MODULES_ROOT";
mkdir $MODULES_ROOT
fi
MODULES_CONFIG_FLAGS=""
for MOD_NAME in `egrep '^##SOURCE ' $0 | awk '{print $2}'`; do
MOD_SRC=`egrep "^##SOURCE\\s+${MOD_NAME}" $0 | awk '{print $3}'`
MOD_FILE="${MOD_NAME}-"`echo "$MOD_SRC" | perl -lape 's|^.*/||g'`
if [ ! -f "$MODULES_ROOT/$MOD_FILE" ]; then
echo "Downloading module $MOD_NAME from $MOD_SRC"
wget -q -O "$MODULES_ROOT/$MOD_FILE" "$MOD_SRC"
fi
MOD_EXTRACT_DIR=`tar tzf $MODULES_ROOT/$MOD_FILE | head -n1 | cut -d/ -f1`
if [ ! -d "$MODULES_ROOT/$MOD_NAME" ]; then
mkdir "$MODULES_ROOT/$MOD_NAME"
fi
if [ ! -d "$MODULES_ROOT/$MOD_NAME/$MOD_EXTRACT_DIR" ]; then
echo "Extracting $MOD_FILE"
tar -C "$MODULES_ROOT/$MOD_NAME" -xzf "$MODULES_ROOT/$MOD_FILE"
fi
MODULES_CONFIG_FLAGS="${MODULES_CONFIG_FLAGS} --add-module=$MODULES_ROOT/$MOD_NAME/$MOD_EXTRACT_DIR"
done
cd "$APP_COMPILE_ROOT"
#
# TODO: add installing ubuntu dependencies for these config options
#
echo "Verifying dependencies"
aptitude -y install \
autoconf \
automake \
gcc \
libbz2-1.0 \
libbz2-dev \
libicu48 \
libicu-dev \
libmysqlclient18 \
mysql-common \
mysql-client-5.5 \
lua5.1 \
liblua5.1-0 \
liblua5.1-0-dev \
libmysqlclient-dev \
libpcre3 \
libpcre3-dev \
libperl-dev \
libsqlite3-0 \
libsqlite3-dev \
libssl1.0.0 \
libssl-dev \
libxslt1-dev \
libtool \
libxml2 \
libxml2-dev \
shtool \
tzdata \
zlib1g \
zlib1g-dev
echo "Setting up silly hacks for ${APP_NAME} to compile"
export LUA_LIB="/usr/lib/x86_64-linux-gnu"
export LUA_INC="/usr/include/lua5.1"
# lua-nginx-module expects -llua to work, but Ubuntu defaults assume we'll use -llua5.1
ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/lib/x86_64-linux-gnu/liblua.so
echo "Configuring ${APP_NAME}"
./configure \
--prefix="$APP_PREFIX" \
--conf-path=${APP_PREFIX}/etc/nginx/nginx.conf \
--error-log-path=${APP_PREFIX}/var/log/nginx/error.log \
--http-client-body-temp-path=${APP_PREFIX}/var/lib/nginx/body \
--http-fastcgi-temp-path=${APP_PREFIX}/var/lib/nginx/fastcgi \
--http-log-path=${APP_PREFIX}/var/log/nginx/access.log \
--http-proxy-temp-path=${APP_PREFIX}/var/lib/nginx/proxy \
--lock-path=${APP_PREFIX}/var/lock/nginx.lock \
--pid-path=${APP_PREFIX}/run/nginx.pid \
--with-pcre-jit \
--with-debug \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--with-http_perl_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_xslt_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--with-ipv6 \
--with-sha1=/usr/include/openssl \
--with-md5=/usr/include/openssl \
$MODULES_CONFIG_FLAGS
if [ $? -ne 0 ]; then
echo "There was an error configuring ${APP_NAME}, bailing out now"
exit 1
fi
echo "Making ${APP_NAME}"
make -j4
if [ $? -ne 0 ]; then
echo "There was an error making ${APP_NAME}, bailing out now"
exit 1
fi
echo "Installing ${APP_NAME}"
make install
#!/bin/bash
APP_NAME="php"
APP_VER="5.3.23"
APP_SRC="http://www.php.net/get/php-${APP_VER}.tar.gz/from/us2.php.net/mirror"
APP_CKSUM="9cd92b0de2b51dcd372f46fa623984f4"
CH_TMP="/tmp/ch_install"
APP_COMPILE_ROOT="$CH_TMP/$APP_NAME-$APP_VER"
APP_PREFIX="/usr/local/$APP_NAME-${APP_VER}"
APP_ARCH="$CH_TMP/$APP_NAME-$APP_VER.tar.gz"
if [ ! -d $CH_TMP ]; then
echo "Creating install directory: $CH_TMP";
mkdir $CH_TMP
fi
cd "$CH_TMP"
if [ ! -f "$APP_ARCH" ]; then
echo "Downloading $APP_NAME $APP_VER: $APP_SRC"
wget -O "$APP_ARCH" "$APP_SRC"
else
echo "Detected existing archive for $APP_NAME $APP_VER: $APP_ARCH"
fi
APP_FOUND_CKSUM=`md5sum $APP_ARCH | cut -d' ' -f1`
if [ "$APP_CKSUM" != "$APP_FOUND_CKSUM" ]; then
echo "Downloaded $APP_NAME $APP_ARCH has invalid checksum, expected $APP_CKSUM found $APP_FOUND_CKSUM"
exit 1
fi
if [ -d "$APP_COMPILE_ROOT" ]; then
echo "PHP archive already extracted"
else
echo "Extracting $APP_NAME"
tar -xzf "$APP_ARCH"
fi
cd "$APP_COMPILE_ROOT"
#
# TODO: add installing ubuntu dependencies for these config options
#
echo "Verifying dependencies"
aptitude -y install \
autoconf \
automake \
g++ \
libaspell15 \
libaspell-dev \
libbz2-1.0 \
libbz2-dev \
libc-client2007e \
libcurl3 \
libcurl3-dev \
libdb5.1 \
libdb5.1-dev \
libedit2 \
libgd2-xpm \
libgd2-xpm-dev \
libgmp10 \
libgmp10-dev \
libicu48 \
libicu-dev \
libmagic1 \
libmagickcore-dev \
libmagickwand5 \
libmagickwand-dev \
libmcrypt4 \
libmysqlclient18 \
mysql-common \
mysql-client-5.5 \
libmysqlclient-dev \
libpcre3 \
libpcre3-dev \
libsqlite3-0 \
libsqlite3-dev \
libssl1.0.0 \
libssl-dev \
libtidy-dev \
libtidy-0.99-0 \
libxslt1-dev \
tidy \
libtool \
libt1-dev \
libxml2 \
libxml2-dev \
libxpm4 \
libxpm-dev \
mime-support \
psmisc \
recode \
librecode0 \
librecode-dev \
sed \
shtool \
t1lib-bin \
tzdata \
xorg-dev \
zlib1g \
zlib1g-dev
echo "Setting up silly hacks for PHP to compile"
if [ ! -f /usr/lib/libXpm.a ]; then
ln -s /usr/lib/x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a
fi
if [ -f Makefile ]; then
make clean
fi
echo "Configuring PHP"
./configure \
--prefix="$APP_PREFIX" \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--enable-ctype \
--with-curl \
--disable-debug \
--enable-exif \
--enable-fastcgi \
--enable-fpm \
--with-freetype-dir \
--enable-ftp \
--without-gdbm \
--enable-gd-native-ttf \
--with-gd \
--with-gmp \
--with-iconv \
--enable-intl=shared \
--with-jpeg-dir \
--with-kerberos \
--with-layout=GNU \
--enable-mbstring \
--with-mhash=yes \
--without-mm \
--with-mysqli \
--with-mysql \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pear \
--with-pic \
--with-png-dir \
--with-recode \
--with-regex=php \
--disable-rpath \
--enable-shmop \
--enable-soap \
--enable-sockets \
--with-sqlite3 \
--with-sqlite \
--disable-static \
--with-system-tzdata \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-t1lib \
--with-tidy \
--with-ttf \
--enable-wddx \
--with-xmlrpc=shared \
--with-xsl \
--enable-zip \
--with-zlib \
--with-xpm-dir
if [ $? -ne 0 ]; then
echo "There was an error configuring PHP, bailing out now"
exit 1
fi
echo "Making PHP"
make -j4
if [ $? -ne 0 ]; then
echo "There was an error making PHP, bailing out now"
exit 1
fi
echo "Installing PHP"
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment