Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created January 3, 2014 22:40
Show Gist options
  • Save roxlu/8248075 to your computer and use it in GitHub Desktop.
Save roxlu/8248075 to your computer and use it in GitHub Desktop.
NGINX + PHP on Mac 10.9 - WIP
#!/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
function check_file {
f=${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 ${to_name} ] ; then
tar -zxvf ${f}
mv ${from_name} ${to_name}
fi
}
autoconf_file="autoconf-2.69.tar.gz"
automake_file="automake-1.14.tar.gz"
libtool_file="libtool-2.4.2.tar.gz"
nginx_file="nginx-1.5.8.tar.gz"
pcre_file="pcre-8.34.tar.gz"
ssl_file="openssl-1.0.1e.tar.gz"
iconv_file="libiconv-1.14.tar.gz"
php_file="php-5.5.7.tar.gz"
gettext_file="gettext-0.18.3.1.tar.gz"
png_file="libpng-1.6.8.tar.gz"
jpg_file="jpegsrc.v9.tar.gz"
freetype_file="freetype-2.5.2.tar.gz"
curl_file="curl-7.34.0.tar.gz"
mcrypt_file="libmcrypt-2.5.8.tar.gz"
xml_file="libxml2-2.9.1.tar.gz"
mysql_file="mysql-5.6.15.tar.gz"
bd=${PWD}
build_dir=${bd}/build/
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 ${iconv_file} "libiconv-1.14" "iconv"
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" "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 ${bd}/pcre
./configure --prefix=${build_dir}
make
make install
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 ${bd}/autoconf
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/automake ] ; then
cd ${bd}/automake
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/libtool ] ; then
cd libtool
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/bin/gettext ] ; then
cd gettext
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/iconv.h ] ; then
cd iconv
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/png.h ] ; then
cd png
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/jpeglib.h ] ; then
cd jpg
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/freetype2/freetype.h ] ; then
cd freetype
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/curl/curl.h ] ; then
cd curl
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -f ${build_dir}/include/mcrypt.h ] ; then
cd mcrypt
./configure --prefix=${build_dir}
make
make install
fi
if [ ! -d ${build_dir}/include/libxml2 ] ; then
cd xml
./configure --prefix=${build_dir}
make
make install
fi
# begin mysql
# cd mysql
# if [ ! -d compile ] ; then
# mkdir compile
# fi
#
# cd compile
# cmake -DCMAKE_INSTALL_PREFIX=${build_dir} ../
# make
# make install
# end mysql
cd php
./configure \
--prefix=${build_dir} \
# --with-mysql=${mysql_dir} \
# --with-pdo-mysql=${mysql_dir}/bin/mysql_config \
--with-iconv=${build_dir} \
--with-png-dir=${build_dir} \
--with-jpeg-dir=${build_dir} \
--with-curl=${build_dir} \
--with-libxml-dir=${build_dir} \
--with-freetype=${build_dir} \
--with-mcrypt=${build_dir} \
--with-zlib \
--with-gd \
--with-mhash \
--with-ldap \
--with-iconv \
--with-freetype \
--without-pear \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-exif \
--enable-bcmath \
--enable-soap \
--enable-zip \
--enable-sockets \
--enable-exit \
--enable-ftp \
--enable-shared=yes \
--enable-static=yes
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