Skip to content

Instantly share code, notes, and snippets.

@akagomez
Forked from hunterloftis/gist:1025903
Created June 14, 2011 21:26
Show Gist options
  • Save akagomez/1025933 to your computer and use it in GitHub Desktop.
Save akagomez/1025933 to your computer and use it in GitHub Desktop.
Install Git, Node, NPM, Nginx, PHP (Fast CGI), CouchDB, and MySQL on Ubuntu 10.04 LTS
# This should be run on a new Linode Ubuntu 32-bit 10.04 image as root to prepare it for Nginx, PHP, MySQL, Node, CouchDB environment
# To start, something like this works:
# scp prepare_server.sh root@123.456.789.10:/root
# First, install basic linux utilities (compilers, git, libssl)
cd /root
mkdir /src
cd src
apt-get update
apt-get upgrade
apt-get install build-essential libssl-dev
# Install git
cd /root/src/
wget http://kernel.org/pub/software/scm/git/git-1.7.1.tar.gz
tar xvzf git-1.7.1.tar.gz
cd git-1.7.1/
./configure
make && make install
# Install node v0.4.8
cd /root/src/
wget https://github.com/joyent/node/zipball/v0.4.8
unzip v0.4.8
cd joyent-node*
export JOBS=4
./configure
make
make install
# Install npm
cd /root/src/
mkdir npm
cd npm
curl http://npmjs.org/install.sh | sh
# Install Redis
cd /opt/
mkdir /opt/redis
wget http://redis.googlecode.com/files/redis-2.2.8.tar.gz
tar -zxvf /opt/redis-2.2.8.tar.gz
cd /opt/redis-2.2.8/
make
cp /opt/redis-2.2.8/redis.conf /opt/redis/redis.conf.default
cp /opt/redis-2.2.8/src/redis-benchmark /opt/redis/
cp /opt/redis-2.2.8/src/redis-cli /opt/redis/
cp /opt/redis-2.2.8/src/redis-server /opt/redis/
cp /opt/redis-2.2.8/src/redis-check-aof /opt/redis/
cp /opt/redis-2.2.8/src/redis-check-dump /opt/redis/
echo "
daemonize yes
pidfile /var/run/redis.pid
logfile /var/log/redis.log
port 6379
bind 127.0.0.1
timeout 300
loglevel notice
## Default configuration options
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /opt/redis/
appendonly no
glueoutputbuf yes
" > /opt/redis/redis.conf
cd /opt/
wget -O init-deb.sh http://library.linode.com/assets/630-redis-init-deb.sh
adduser --system --no-create-home --disabled-login --disabled-password --group redis
mv /opt/init-deb.sh /etc/init.d/redis
chmod +x /etc/init.d/redis
chown -R redis:redis /opt/redis
touch /var/log/redis.log
chown redis:redis /var/log/redis.log
update-rc.d -f redis defaults
# Install couchdb
# http://wiki.apache.org/couchdb/Installing_on_Ubuntu
cd /root/src/
# Prerequisites
apt-get build-dep couchdb
apt-get install xulrunner-1.9.2-dev libicu-dev libcurl4-gnutls-dev libtool
# http://wiki.apache.org/couchdb/Installing_on_Ubuntu#xulrunner.conf
echo "/usr/lib/xulrunner-1.9.2.18
/usr/lib/xulrunner-devel-1.9.2.18
" > /etc/ld.so.conf.d/xulrunner.conf
/sbin/ldconfig
# Install
wget http://apache.tradebit.com/pub//couchdb/1.1.0/apache-couchdb-1.1.0.tar.gz
tar -zxvf apache-couchdb-1.1.0.tar.gz
cd apache-couchdb-1.1.0
./configure --with-js-include=/usr/lib/xulrunner-devel-1.9.2.18/include --with-js-lib=/usr/lib/xulrunner-devel-1.9.2.18/lib
make && make install
# Security
# http://guide.couchdb.org/draft/source.html#security
adduser --system --home /usr/local/var/lib/couchdb --no-create-home --shell /bin/bash --group --gecos "CouchDB" couchdb
chown -R couchdb:couchdb /usr/local/etc/couchdb
chown -R couchdb:couchdb /usr/local/var/lib/couchdb
chown -R couchdb:couchdb /usr/local/var/log/couchdb
chown -R couchdb:couchdb /usr/local/var/run/couchdb
chmod -R 0770 /usr/local/etc/couchdb
chmod -R 0770 /usr/local/var/lib/couchdb
chmod -R 0770 /usr/local/var/log/couchdb
chmod -R 0770 /usr/local/var/run/couchdb
# Startup
ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb
update-rc.d couchdb defaults
/etc/init.d/couchdb start
# Install Nginx
# http://www.celavi.org/2010/06/26/how-to-install-nginx-with-php5-fastcgi-and-mysql-support-on-ubuntu-10-4-lts/
cd /root/src/
apt-get install nginx
/etc/init.d/nginx start
update-rc.d nginx defaults
apt-get install spawn-fcgi
# Install FastCGI + PHP5
cd /root/src/
apt-get install spawn-fcgi
apt-get install php5 php5-cli php5-common php5-suhosin php5-cgi php-pear php5-mysql
touch /usr/sbin/fastcgi-php
echo '#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
start() {
echo -n "Starting PHP FastCGI: "
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo "$PHP_CGI_NAME."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL' > /etc/init.d/php-fastcgi
chmod +x /etc/init.d/php-fastcgi
service php-fastcgi start
sudo update-rc.d php-fastcgi defaults
# Install MySQL
cd /root/src/
apt-get install mysql-server mysql-client
# (Dump of my open tabs)
# http://guide.couchdb.org/draft/source.html#debian
# http://www.khmer365.com/index.php?topic=5549.0
# http://www.celavi.org/2010/06/26/how-to-install-nginx-with-php5-fastcgi-and-mysql-support-on-ubuntu-10-4-lts/
# http://dailyjs.com/2010/03/15/hosting-nodejs-apps/
# http://wiki.apache.org/couchdb/Installing_on_Ubuntu
# http://wiki.apache.org/couchdb/Installing_on_Ubuntu#xulrunner.conf
# http://guide.couchdb.org/draft/source.html#security
# http://awebfactory.com.ar/node/467
# http://kibyegon.wordpress.com/2010/05/13/how-to-install-git-on-ubuntu-lucid-10-04/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment