Skip to content

Instantly share code, notes, and snippets.

@camshaft
Created June 9, 2011 04:04
Show Gist options
  • Save camshaft/1016036 to your computer and use it in GitHub Desktop.
Save camshaft/1016036 to your computer and use it in GitHub Desktop.
Mac + Nginx + MongoDB + PHP
#!/bin/bash
# vars
PHP_VERSION="5.3.6"
NGINX_VERSION="1.0.4"
MONGO_VERSION="1.8.1"
MEMCACHED_VERSION="1.4.5"
DIRECTORY=$(cd `dirname $0` && pwd)
PHP_DIR=$DIRECTORY/lib/php/$PHP_VERSION/
NGINX_DIR=$DIRECTORY/lib/nginx/$NGINX_VERSION/
MONGO_DIR=$DIRECTORY/lib/mongodb/$MONGO_VERSION/
MEMCACHED_DIR=$DIRECTORY/lib/memcached/$MEMCACHED_VERSION/
PHP_URL=http://us.php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror
NGINX_URL=http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
MONGO_FILE=mongodb-osx-x86_64-$MONGO_VERSION
MONGO_URL=http://downloads.mongodb.org/osx/$MONGO_FILE.tgz
MEMCACHED_URL=http://memcached.googlecode.com/files/memcached-$MEMCACHED_VERSION.tar.gz
# init directory
mkdir $DIRECTORY/bin
mkdir $DIRECTORY/etc
mkdir $DIRECTORY/lib
mkdir $DIRECTORY/src
mkdir $DIRECTORY/var
######## PHP INSTALL #########
cd $DIRECTORY/src
curl -L $PHP_URL | tar zx
cd php-$PHP_VERSION
./configure --enable-fastcgi --enable-fpm --with-zlib --enable-mbstring --disable-pdo --with-curl --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --prefix=$PHP_DIR
make all install
#symlinks
ln -s $PHP_DIR $DIRECTORY/lib/php/CURRENT/
#bin
ln -s $DIRECTORY/lib/php/CURRENT/bin/php $DIRECTORY/bin/php
ln -s $DIRECTORY/lib/php/CURRENT/bin/pear $DIRECTORY/bin/pear
ln -s $DIRECTORY/lib/php/CURRENT/bin/pecl $DIRECTORY/bin/pecl
ln -s $DIRECTORY/lib/php/CURRENT/bin/phpize $DIRECTORY/bin/phpize
#config
#TODO get a php.ini file
#ln -s $DIRECTORY/lib/php/CURRENT/etc/php.ini $DIRECTORY/etc/php.ini
#ln -s $DIRECTORY/lib/php/CURRENT/etc/
$DIRECTORY/bin/pecl install apc
$DIRECTORY/bin/pecl install memcached
######## NGINX INSTALL #########
cd $DIRECTORY/src
curl -L $NGINX_URL | tar zx
cd nginx-$NGINX_VERSION
./configure --sbin-path=$NGINX_DIR/sbin/ --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --prefix=$NGINX_DIR
make install
#symlinks
ln -s $NGINX_DIR $DIRECTORY/lib/nginx/CURRENT/
ln -s $DIRECTORY/lib/nginx/CURRENT/sbin/nginx $DIRECTORY/bin/nginx
ln -s $DIRECTORY/lib/nginx/CURRENT/nginx.conf $DIRECTORY/etc/nginx.conf
######## MONGO INSTALL #########
cd $DIRECTORY/src
curl -L $MONGO_URL | tar zx
mv $MONGO_FILE $MONGO_DIR
mkdir $DIRECTORY/var/mongodb
#symlinks
ln -s $MONGO_DIR $DIRECTORY/lib/mongodb/CURRENT/
ln -s $DIRECTORY/lib/mongodb/CURRENT/bin/mongo $DIRECTORY/bin/mongo
ln -s $DIRECTORY/lib/mongodb/CURRENT/bin/mongod $DIRECTORY/bin/mongod
$DIRECTORY/bin/pecl install mongo
#### MEMCACHED INSTALL ####
cd $DIRECTORY/src
curl -L $MEMCACHED_URL | tar zx
cd memcached-$MEMCACHED_VERSION
./configure --prefix=$MEMCACHED_DIR
make install
#symlinks
ln -s $MEMCACHED_DIR $DIRECTORY/lib/memcached/CURRENT/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment