Skip to content

Instantly share code, notes, and snippets.

@daqing
Created February 16, 2009 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daqing/64971 to your computer and use it in GitHub Desktop.
Save daqing/64971 to your computer and use it in GitHub Desktop.
#! /bin/bash
# install nginx + php5(with apc & memcache extensions) + mysql
# install php5 first
echo "* installing PHP 5 with extension APC, Xdebug and Memcache..."
sudo aptitude install -y \
php5-cli \
php5-cgi \
php-apc \
php5-xdebug \
php5-memcache \
build-essential \
mysql-client-5.0 \
mysql-server-5.0 \
phpmyadmin \
1>/dev/null 2>/tmp/lnmp.log
# install nginx
echo "* installing nginx..."
sudo aptitude install -y nginx 1>/dev/null 2>>/tmp/lnmp.log
echo "* configuring nginx..."
# configure nginx
# cat /etc/nginx/site-enabled/default > /etc/nginx/site-enabled/hackban
# install spawn-fcgi from lighttpd
echo "* installing spawn-fcgi..."
if [ ! -f "/usr/bin/spawn-fcgi" ]; then
cd /tmp/
wget -c http://www.lighttpd.net/download/lighttpd-1.4.20.tar.bz2 1>/dev/null 2>/dev/null
if [ -f "lighttpd-1.4.20.tar.bz2" ]; then
tar -xjf lighttpd-1.4.20.tar.bz2
cd lighttpd-1.4.20
# to compile lighttpd, we need to install pcre-devel package
sudo aptitude install -y libpcre3-dev 1>/dev/null 2>>/tmp/lnmp.log
./configure --without-bzip2 1>/dev/null 2>>/tmp/lnmp.log && make 1>/dev/null 2>>/tmp/lnmp.log
if [ -f "src/spawn-fcgi" ]; then
sudo cp src/spawn-fcgi /usr/bin/
else
echo "* spawn-fcgi was not compiled."
exit;
fi
else
echo "* download lighttpd(version 1.4.20) failed."
exit;
fi
fi
# create scripts for spawning PHP fastcgi processes
echo "* creating php-fastcgi script in /usr/bin..."
if [ ! -f "/usr/bin/php-fastcgi" ]; then
echo -e "#! /bin/bash\n\
/usr/bin/spawn-fcgi \
-a 127.0.0.1 \
-p 1986 \
-u www-data \
-f /usr/bin/php5-cgi" \
| sudo tee /usr/bin/php-fastcgi 1>/dev/null
fi
if [ -f "/usr/bin/php-fastcgi" ]; then
# make it executable
sudo chmod +x /usr/bin/php-fastcgi
else
echo "* create php-fastcgi failed."
exit;
fi
# create init script
echo "* creating init-fastcgi script in /etc/init.d..."
if [ ! -f "/etc/init.d/init-fastcgi" ]; then
echo -e "#! /bin/bash\n\
PHP_SCRIPT=/usr/bin/php-fastcgi\n\
RETVAL=0\n\
case \"\$1\" in\n\
start)\n\
\$PHP_SCRIPT\n\
RETVAL=\$?\n\
;;\n\
stop)\n\
sudo killall -g php5-cgi\n\
RETVAL=\$?\n\
;;\n\
restart)\n\
sudo killall -g php5-cgi\n\
\$php_script\n\
RETVAL=\$?\n\
;;\n\
*)\n\
echo \"Usage: init-fastcgi {start|stop|restart}\"\n\
exit 1\n\
;;\n\
esac\n\
\n\
exit \$RETVAL" \
| sed -e 's/^ //' | sudo tee /etc/init.d/init-fastcgi 1>/dev/null
if [ -f "/etc/init.d/init-fastcgi" ]; then
sudo chmod 755 /etc/init.d/init-fastcgi
else
echo "* create init script failed."
exit
fi
fi
echo "* finish."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment