Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created December 28, 2014 18:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/448c7a48519ff774e699 to your computer and use it in GitHub Desktop.
Save roxlu/448c7a48519ff774e699 to your computer and use it in GitHub Desktop.
Apache, PHP and MySQL build script for Mac 10.10
#!/bin/bash
d=${PWD}
sd=${d}/sources
bd=${d}/build
id=${d}/installed/
PATH_ORIG=${PATH}
CC_ORIG=${CC}
CPP_ORIG=${CPP}
function set_env_new {
export PATH=${id}/bin:${id}:${PATH}
export CC=/usr/bin/cc
export CPP=/usr/bin/cpp
}
function set_env_old {
export PATH=${PATH_ORIG}
export CC=${CC_ORIG}
export CPP=${CPP_ORIG}
}
set_env_new
if [ ! -d ${sd} ] ; then
mkdir ${sd}
fi
if [ ! -d ${bd} ] ; then
mkdir ${bd}
fi
if [ ! -d ${id} ] ; then
mkdir ${id}
fi
# Download libtool
if [ ! -d ${sd}/libtool ] ; then
cd ${sd}
if [ ! -f libtool.tar.gz ] ; then
curl -L -o libtool.tar.gz http://ftpmirror.gnu.org/libtool/libtool-2.4.4.tar.gz
fi
tar -zxvf libtool.tar.gz
mv libtool-2.4.4 libtool
fi
# Download autoconf
if [ ! -d ${sd}/autoconf ] ; then
cd ${sd}
if [ ! -f autoconf.tar.gz ] ; then
curl -L -o autoconf.tar.gz http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
fi
tar -zxvf autoconf.tar.gz
mv autoconf-2.69 autoconf
fi
# Download Apache
if [ ! -d ${sd}/apache ] ; then
cd ${sd}
if [ ! -f apache.tar.gz ] ; then
curl -L -o apache.tar.gz http://apache.proserve.nl//httpd/httpd-2.4.10.tar.gz
fi
tar -zxvf apache.tar.gz
mv httpd-2.4.10 apache
fi
# Download php
if [ ! -d ${sd}/php ] ; then
cd ${sd}
if [ ! -f php.tar.gz ] ; then
curl -L -o php.tar.gz http://de1.php.net/get/php-5.6.4.tar.gz/from/this/mirror
fi
tar -zxvf php.tar.gz
mv php-5.6.4 php
fi
# Download pcre
if [ ! -d ${sd}/pcre ] ; then
cd ${sd}
if [ ! -f pcre.tar.gz ] ; then
curl -L -o pcre.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
fi
tar -zxvf pcre.tar.gz
mv pcre-8.36 pcre
fi
# Download APR
if [ ! -d ${sd}/apr ] ; then
cd ${sd}
if [ ! -f apr.tar.gz ] ; then
curl -L -o apr.tar.gz http://mirrors.supportex.net/apache//apr/apr-1.5.1.tar.gz
fi
tar -zxvf apr.tar.gz
mv apr-1.5.1 apr
fi
# Download APR-util
if [ ! -d ${sd}/apr-util ] ; then
cd ${sd}
if [ ! -f apr-util.tar.gz ] ; then
curl -L -o apr-util.tar.gz http://mirrors.supportex.net/apache//apr/apr-util-1.5.4.tar.gz
fi
tar -zxvf apr-util.tar.gz
mv apr-util-1.5.4 apr-util
fi
# Download MySQL
if [ ! -d ${sd}/mysql ] ; then
cd ${sd}
if [ ! -f mysql.tar.gz ] ; then
curl -L -o mysql.tar.gz http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz
fi
tar -zxvf mysql.tar.gz
mv mysql-5.6.22 mysql
fi
# Download libpng (for php)
if [ ! -d ${sd}/png ] ; then
cd ${sd}
if [ ! -f png.tar.gz ] ; then
curl -L -o png.tar.gz http://prdownloads.sourceforge.net/libpng/libpng-1.6.15.tar.gz?download
fi
tar -zxvf png.tar.gz
mv libpng-1.6.15 png
fi
# Download libjpeg
if [ ! -d ${sd}/jpg ] ; then
cd ${sd}
if [ ! -f jpg.zip ] ; then
curl -L -o jpg.zip http://downloads.sourceforge.net/project/libjpeg/libjpeg/6b/jpegsr6.zip
fi
unzip jpg.zip
mv jpeg-6b jpg
fi
# Download libmcrypt
if [ ! -d ${sd}/mcrypt ] ; then
cd ${sd}
if [ ! -f mcrypt.tar.gz ] ; then
curl -o mcrypt.tar.gz -L http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
fi
tar -zxvf mcrypt.tar.gz
mv libmcrypt-2.5.8 mcrypt
fi
# Download libxml
if [ ! -d ${sd}/xml ] ; then
cd ${sd}
if [ ! -f xml.tar.gz ] ; then
curl -o xml.tar.gz -L ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz
fi
tar -zxvf xml.tar.gz
mv libxml2-2.9.2 xml
fi
# Download libcurl
if [ ! -d ${sd}/curl ] ; then
cd ${sd}
if [ ! -f curl.tar.gz ] ; then
curl -o curl.tar.gz -L http://curl.haxx.se/download/curl-7.39.0.tar.gz
fi
tar -zxvf curl.tar.gz
mv curl-7.39.0 curl
fi
# Download libz
if [ ! -d ${sd}/zlib ] ; then
cd ${sd}
if [ ! -f zlib.tar.gz ] ; then
curl -o zlib.tar.gz -L http://zlib.net/zlib-1.2.8.tar.gz
fi
tar -zxvf zlib.tar.gz
mv zlib-1.2.8 zlib
fi
# Download libiconv
if [ ! -d ${sd}/iconv ] ; then
cd ${sd}
if [ ! -f iconv.tar.gz ] ; then
curl -o iconv.tar.gz -L http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
fi
tar -zxvf iconv.tar.gz
mv libiconv-1.14 iconv
fi
# Compile libtool
if [ ! -f ${id}/bin/libtool ] ; then
cd ${sd}/libtool
./configure \
--prefix=${id}
make
make install
fi
# Compile autoconf
if [ ! -f ${id}/bin/autoconf ] ; then
cd ${sd}/autoconf
./configure --prefix=${id}
make
make install
fi
# Compile apr
if [ ! -f ${id}/lib/libapr-1.a ] ; then
cd ${bd}
if [ ! -d apr ] ; then
mkdir apr
fi
cd apr
${sd}/apr/configure \
--prefix=${id}
make
make install
fi
# Compile apr-util
if [ ! -f ${id}/lib/libaprutil-1.a ] ; then
cd ${bd}
if [ ! -d apr-util ] ; then
mkdir apr-util
fi
cd apr-util
${sd}/apr-util/configure \
--prefix=${id} \
--with-apr=${id}/bin
make
make install
fi
# Compile pcre
if [ ! -f ${id}/lib/libpcre.a ] ; then
cd ${bd}
if [ ! -d pcre ] ; then
mkdir pcre
fi
cd pcre
${sd}/pcre/configure \
--enable-static=yes \
--enable-shared=no \
--prefix=${id}
make
make install
fi
# Compile apache
if [ ! -f ${id}/bin/apachectl ] ; then
cd ${bd}
if [ -d apache ] ; then
rm -rf apache
fi
mkdir apache
cd apache
cd ${bd}/apache
${sd}/apache/configure \
--prefix=${id}
make
make install
fi
# Compile MySQL
if [ ! -f ${id}/bin/mysqld_safe ] ; then
if [ ! -d ${bd}/mysql ] ; then
mkdir ${bd}/mysql
fi
cd ${bd}/mysql
cmake -DCMAKE_INSTALL_PREFIX=${id} \
${sd}/mysql/
make
make install
# Install MySQL database.
if [ ! -f ${id}/mysql_install_db ] ; then
cp ${id}/scripts/mysql_install_db ${id}
cd ${id}
./mysql_install_db
fi
fi
# Compile libz
if [ ! -f ${id}/lib/libz.a ] ; then
cd ${sd}/zlib
./configure --prefix=${id}
make
make install
fi
# Compile libpng
if [ ! -f ${id}/lib/libpng.a ] ; then
if [ ! -d ${bd}/png ] ; then
mkdir ${bd}/png
fi
set_env_old
cd ${bd}/png
${sd}/png/configure --prefix=${id} \
--enable-shared=no \
--enable-static=yes
make
make install
set_env_new
fi
# Compile libjpg: TODO build script of libjpeg is borked!
if [ 0 -eq 1 ] ; then
cd ${bd}
if [ ! -d jpg ] ; then
mkdir jpg
fi
set -x
cd jpg
cd ${sd}/jpg/
./configure --prefix=${id} \
--enable-shared=no \
--enable-static=yes
make
make install
fi
# Compile mcrypt
if [ ! -f ${id}/lib/libmcrypt.a ] ; then
cd ${sd}/mcrypt
./configure --prefix=${id} \
--enable-shared=no \
--enable-static=yes
make
make install
fi
# Compile iconv
if [ ! -f ${id}/lib/libiconv.a ] ; then
cd ${sd}/iconv
./configure --prefix=${id} \
--enable-static-yes \
--enable-shared=no
make
make install
fi
# Compile libxml
if [ ! -f ${id}/lib/libxml2.a ] ; then
cd ${bd}
if [ ! -d libxml ] ; then
mkdir libxml
fi
cd ${bd}/libxml
${sd}/xml/configure --prefix=${id} \
--enable-shared=no \
--enable-static=yes \
--with-iconv=${id}
make
make install
fi
# Compile libcurl
if [ ! -f ${id}/lib/libcurl.a ] ; then
cd ${bd}
if [ ! -d libcurl ] ; then
mkdir libcurl
fi
cd libcurl
${sd}/curl/configure --prefix=${id} \
--enable-static=yes \
--enable-shared=no
make
make install
fi
# Compile php
if [ 1 -eq 1 ] ; then
# --with-jpeg-dir=${id} \
# --with-freetype=${id} \
# --with-ldap \
if [ ! -d ${bd}/php ] ; then
mkdir ${bd}/php
fi
export LIBS="-lresolv"
export DYLD_LIBRARY_PATH=${id}/lib/:${DYLD_LIBRARY_PATH}
cd ${bd}/php
${sd}/php/configure --prefix=${id} \
--without-pear \
--with-apxs2=${id}/bin/apxs \
--with-mysql=${id} \
--with-pdo-mysql=${id}/bin/mysql_config \
--with-png-dir=${id} \
--with-curl=${id} \
--with-libxml-dir=${id} \
--with-mcrypt=${id} \
--with-zlib=${id} \
--with-iconv=${id} \
--with-gd \
--with-mhash \
--enable-mbstring \
--enable-ftp \
--enable-exif \
--enable-bcmath \
--enable-soap \
--enable-sockets \
--enable-ftp \
--enable-zip \
--enable-shared=yes \
--enable-static=yes \
--enable-opcache=no
make
make install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment