#!/bin/sh # Compiling nginx + php + mysql on Mac OSX 10.9 # --------------------------------------------- # # # CONFIGURE # --------------- # 1) Edit `conf/nginx.conf` and add this to the between the server { ... } config. # NOTE: the current config you only need to uncomment the example that looks like this, # BUT MAKE SURE THAT YOU remove the "scripts" with "$document_root" as below.: # # location ~ \.php$ { # include fastcgi_params; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_pass php; # # SEE: https://gist.github.com/roxlu/c35ce2f95690fa0a9283 for an example nginx config. # # 2) Rename `etc/php-fpm.conf.default` to `etc/php-fpm.conf` # # 3) Create `start_nginx.sh` in this directory, with: # # #!/bin/sh # export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} # cd build/sbin # ./nginx # # 4) Create `stop_nginx.sh` in this directory, with: # # #!/bin/sh # export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} # cd build/sbin # ./nginx -s stop # # 5) Create `start_php.sh` in this directory, with: # # #!/bin/sh # export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} # cd build/sbin # ./php-fpm -F # # 6) Create `start.sh` in this directory with: # # # 7) Setup MySQL # - Go to build/ # # - Execute: # $ ./scripts/mysql_install_db # # - Edit build/my.cnf # # [mysqld] # datadir=/path/to/build/data/ # # - Change permissions: # $ cd build # $ chmod -R 777 data/* # $ chmod 777 data # # - Start mysql # # - Set password # % ./bin/mysqladmin -u root password 'YOUR PASSWORD' 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 if [ ! -f ${build_dir}/sbin/php-fpm ] ; then 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 fi if [ ! -f ${build_dir}/sbin/nginx ] ; then cd ${sd}/nginx ./configure --prefix=${build_dir} \ --with-pcre=${sd}/pcre \ --with-http_ssl_module \ --with-cc-opt="-m64 -arch x86_64" \ --with-ld-opt="-m64 -arch x86_64" make make install fi