Nginx, PHP and MySQL Installation Script 08-31-2013, 05:55 PM
#1
A while back a dal33t showed me a simple script he made to automatically install Nginx, PHP and MySQL (for Debian Squeeze). Just thought it might be worth sharing if any of you bought a VPS. Simple, saves a few minutes of time, and I found it useful when I was helping a friend.
Code:
#! /bin/sh
##############################################
# chkconfig: 2345 90 10 #
# Installer - makes server ready for use #
##############################################
if [[ $# != 1 ]]
then echo "Nginx, PHP5 and MySQL installer by DaL33T"
echo "Arguments: sh installer.sh <website URL w/o www.>"
exit 0
fi
echo "[*] Installing..."
apt-get update
#Install nano
echo "[*] Installing Nano..."
apt-get install -qq --force-yes nano
#Install nginx
echo "[*] Installing Nginx..."
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
rm nginx_signing.key
echo "deb http://nginx.org/packages/debian/ squeeze nginx" | sh -c 'cat >> /etc/apt/sources.list'
echo "deb-src http://nginx.org/packages/debian/ squeeze nginx" | sh -c 'cat >> /etc/apt/sources.list'
apt-get update
service apache2 stop
apt-get install -qq --force-yes nginx
cd /etc/nginx/conf.d
rm -rf *
echo "server {
listen 80;
server_name www.$1 $1;
location / {
root /var/www;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /var/www;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}" | sh -c 'cat >> default.conf'
#Install mysql
echo "[*] Installing MySQL..."
apt-get install -qq --force-yes mysql-server mysql-client
#Install php5
echo "[*] Installing PHP5..."
echo "deb http://packages.dotdeb.org squeeze all" | sh -c 'cat >> /etc/apt/sources.list'
echo "deb-src http://packages.dotdeb.org squeeze all" | sh -c 'cat >> /etc/apt/sources.list'
wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -
rm dotdeb.gpg
apt-get update
apt-get install -qq --force-yes php5-fpm php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
/etc/init.d/php5-fpm restart
sed -i 's/127.0.0.1:9000/\/tmp\/php5-fpm.sock/g' /etc/php5/fpm/pool.d/www.conf
#Restart nginx/php-fpm
echo "[*] Finishing up..."
service nginx restart
/etc/init.d/php5-fpm restart
echo ""
echo "################################################"
echo "# Nginx, MySQL and PHP5 have been installed on #"
echo "# this server. Thanks for using my script! #"
echo "# #"
echo "# -DaL33T #"
echo "################################################"
exit 0










![[Image: 7ajmN5P.jpg]](https://i.imgur.com/7ajmN5P.jpg)
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)




