Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created January 4, 2014 15:24
Show Gist options
  • Save roxlu/8256400 to your computer and use it in GitHub Desktop.
Save roxlu/8256400 to your computer and use it in GitHub Desktop.
NGINX + PHP on Mac 10.9 (fresh install)
#!/bin/sh
# Compiling nginx + php + mysql on Mac OSX 10.9
# ---------------------------------------------
#
#
# Configure nginx
# ---------------
# Add this to the between the server { ... } config:
#
# --
# location ~ \.php$ {
# include fastcgi_params;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_pass php;
# }
# --
set -x
bd=${PWD}
sd=${bd}/sources/
build_dir=${bd}/build/
function check_file {
f=${sd}/${1}
from_name=${2}
to_name=${3}
if [ ! -f ${f} ] ; then
echo "Please download $f first into this directory."
exit
fi
echo "Found: $f"
if [ ! -d ${sd}/${to_name} ] ; then
cd ${sd}
tar -zxvf ${f}
mv ${from_name} ${to_name}
fi
}
autoconf_file="autoconf-2.69.tar.gz" # http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
automake_file="automake-1.14.tar.gz" # http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
libtool_file="libtool-2.4.2.tar.gz" # http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
nginx_file="nginx-1.5.8.tar.gz" # http://nginx.org/download/nginx-1.5.8.tar.gz
pcre_file="pcre-8.34.tar.gz" # ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
ssl_file="openssl-1.0.1e.tar.gz" # http://www.openssl.org/source/openssl-1.0.1e.tar.gz
php_file="php-5.5.7.tar.gz" # http://nl1.php.net/downloads.php
gettext_file="gettext-0.18.3.1.tar.gz" # http://ftp.gnu.org/pub/gnu/gettext/gettext-0.18.3.1.tar.gz
png_file="libpng-1.6.8.tar.gz" # http://prdownloads.sourceforge.net/libpng/libpng-1.6.8.tar.gz?download
jpg_file="jpegsrc.v9.tar.gz" # http://www.ijg.org/files/jpegsrc.v9.tar.gz
freetype_file="freetype-2.5.2.tar.gz" # http://download.savannah.gnu.org/releases/freetype/freetype-2.5.2.tar.gz
curl_file="curl-7.34.0.tar.gz" # http://curl.haxx.se/download/curl-7.34.0.tar.gz
mcrypt_file="libmcrypt-2.5.8.tar.gz" # http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
xml_file="libxml2-2.9.1.tar.gz" # ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
mysql_file="mysql-5.6.15-osx10.7-x86_64.tar.gz" # http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15-osx10.7-x86.tar.gz
check_file ${nginx_file} "nginx-1.5.8" "nginx"
check_file ${pcre_file} "pcre-8.34" "pcre"
check_file ${ssl_file} "openssl-1.0.1e" "ssl"
check_file ${automake_file} "automake-1.14" "automake"
check_file ${autoconf_file} "autoconf-2.69" "autoconf"
check_file ${libtool_file} "libtool-2.4.2" "libtool"
check_file ${php_file} "php-5.5.7" "php"
check_file ${gettext_file} "gettext-0.18.3.1" "gettext"
check_file ${png_file} "libpng-1.6.8" "png"
check_file ${jpg_file} "jpeg-9" "jpg"
check_file ${freetype_file} "freetype-2.5.2" "freetype"
check_file ${curl_file} "curl-7.34.0" "curl"
check_file ${mcrypt_file} "libmcrypt-2.5.8" "mcrypt"
check_file ${xml_file} "libxml2-2.9.1" "xml"
check_file ${mysql_file} "mysql-5.6.15-osx10.7-x86_64" "mysql"
export PATH="${build_dir}/bin:${PATH}"
export CFLAGS="-I${build_dir}/include/ -m64 -arch x86_64"
export CPPFLAGS=${CFLAGS}
export CXXFLAGS=${CFLAGS}
export LDFLAGS="-L${build_dir}/lib/ "
if [ ! -f ${build_dir}/lib/libpcre.a ] ; then
cd ${sd}/pcre
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/mysql.h ] ; then
cp -r ${sd}/mysql/* ${build_dir}/
fi
# if [ ! -f ${build_dir}/lib/libssl.a ] ; then
# cd ${bd}/ssl
# ./config --prefix=${build_dir}
# make
# make install
# fi
if [ ! -f ${build_dir}/bin/autoconf ] ; then
cd ${sd}/autoconf
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/automake ] ; then
cd ${sd}/automake
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/libtool ] ; then
cd ${sd}/libtool
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/gettext ] ; then
cd ${sd}/gettext
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/png.h ] ; then
cd ${sd}png
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/jpeglib.h ] ; then
cd ${sd}/jpg
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/freetype2/freetype.h ] ; then
cd ${sd}/freetype
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/curl/curl.h ] ; then
cd ${sd}/curl
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/mcrypt.h ] ; then
cd ${sd}/mcrypt
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -d ${build_dir}/include/libxml2 ] ; then
cd ${sd}/xml
./configure --prefix=${build_dir}
make
make install
fi
#export LDFLAGS="${LDFLAGS} -licon"
#echo ${LDFLAGS}
#export LIBS="${LIBS} -licon"
# --with-freetype-dir=${build_dir} \
# \
export DYLD_LIBRARY_PATH=${build_dir}/lib/:${DYLD_LIBRARY_PATH}
export LDFLAGS="-L${build_dir}/lib/ -lxml2 -llzma -lbz2 -lssl -lcrypto -lresolv -lm -lfreetype"
cd ${sd}/php
./configure \
--prefix=${build_dir} \
--enable-opcache=no \
--without-pear \
--with-mysql=${build_dir} \
--with-mysqli=${build_dir}/bin/mysql_config \
--with-png-dir=${build_dir} \
--with-jpeg-dir=${build_dir} \
--with-curl=${build_dir} \
--with-libxml-dir=${build_dir} \
--with-mcrypt=${build_dir} \
--with-zlib \
--with-gd \
--with-mhash \
--with-ldap \
--with-iconv \
--with-freetype \
--enable-mbstring \
--enable-ftp \
--enable-exif \
--enable-bcmath \
--enable-soap \
--enable-zip \
--enable-sockets \
--enable-ftp \
--enable-shared=yes \
--enable-static=yes \
--enable-fpm \
make
make install
exit
cd ${bd}/nginx
./configure --prefix=${build_dir} \
--with-pcre=${bd}/pcre \
# --with-openssl=${bd}/ssl \
--with-http_ssl_module \
--with-cc-opt="-m64 -arch x86_64" \
--with-ld-opt="-m64 -arch x86_64"
make
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment