Created
January 4, 2014 17:01
-
-
Save roxlu/8257407 to your computer and use it in GitHub Desktop.
NGINX + PHP + configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; | |
# | |
# 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: | |
# | |
# | |
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
# '$status $body_bytes_sent "$http_referer" ' | |
# '"$http_user_agent" "$http_x_forwarded_for"'; | |
#access_log logs/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
#gzip on; | |
server { | |
listen 80; | |
server_name localhost; | |
#charset koi8-r; | |
#access_log logs/host.access.log main; | |
location / { | |
root html; | |
index index.html index.htm; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# | |
#location ~ \.php$ { | |
# proxy_pass http://127.0.0.1; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
location ~ \.php$ { | |
root html; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
server { | |
listen 80; | |
server_name roxlu.localhost; | |
root html/roxlu/html; | |
location / { | |
try_files $uri $uri/ @pass_through; | |
} | |
location ~ \.php$ { | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param QUERY_STRING path=$uri&$args; | |
include fastcgi_params; | |
} | |
location @pass_through { | |
root html/roxlu/html; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | |
fastcgi_param SCRIPT_NAME /index.php; | |
fastcgi_param QUERY_STRING path=$uri&$args; | |
} | |
} | |
# another virtual host using mix of IP-, name-, and port-based configuration | |
# | |
#server { | |
# listen 8000; | |
# listen somename:8080; | |
# server_name somename alias another.alias; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
# HTTPS server | |
# | |
#server { | |
# listen 443 ssl; | |
# server_name localhost; | |
# ssl_certificate cert.pem; | |
# ssl_certificate_key cert.key; | |
# ssl_session_cache shared:SSL:1m; | |
# ssl_session_timeout 5m; | |
# ssl_ciphers HIGH:!aNULL:!MD5; | |
# ssl_prefer_server_ciphers on; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
./start_nginx.sh | |
./start_php.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} | |
cd build/sbin | |
./nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} | |
cd build/sbin | |
./php-fpm -F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export DYLD_LIBRARY_PATH=${PWD}/build/lib/:${DYLD_LIBRARY_PATH} | |
cd build/sbin | |
./nginx -s stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment