LEMP_lib

by rnolen
50 deployments · 1 still active · last rev. 4 years ago

Collection of functions for a LEMP stack.

In this script I aimed for readability so users may readily discern precisely what is happening to their server.

Compatible with: No distros currently supported
						#!/bin/bash

#################################
#  system update    #
#################################

function lemp_system_update_aptitude {

#add dotdeb repo
  echo -e "\ndeb http://packages.dotdeb.org squeeze all\ndeb-src http://packages.dotdeb.org squeeze all\ndeb http://packages.dotdeb.org squeeze-php54 all\ndeb-src http://packages.dotdeb.org squeeze-php54 all" >> /etc/apt/sources.list

#add dotdeb key
  wget http://www.dotdeb.org/dotdeb.gpg
  apt-key add dotdeb.gpg

#i prefer aptitude. you may not.
  aptitude update
  aptitude -y full-upgrade #only sissies use safe-upgrade. ARE YOU A SISSY?


}


#################################
#  mysql install    #
#################################

function lemp_mysql_install {

#not going to install mysql from dotdeb. if you want to, remove this entry from /etc/apt/preferences and aptitude update.
  echo -e "Package: libmysqlclient-dev libmysqlclient16 libmysqld-dev libmysqld-pic mysql-client-5.1 mysql-client mysql-common mysql-server-5.1 mysql-server-core-5.1 mysql-server \nPin: release o=Debian \nPin-Priority: 900" >> /etc/apt/preferences

  echo "mysql-server-5.1 mysql-server/root_password password $DB_PASSWORD" | debconf-set-selections
  echo "mysql-server-5.1 mysql-server/root_password_again password $DB_PASSWORD" | debconf-set-selections
  aptitude -y install mysql-server

}

#################################
#  PHP-FPM      #
#################################

function lemp_php-fpm {

#installing only the basics.
  aptitude install -y php5-fpm php5-mysql php5

#php5-fpm conf

#
#nice strict permissions
  sed -i 's/;listen.owner = www-data/listen.owner = www-data/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/;listen.group = www-data/listen.group = www-data/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/;listen.mode = 0666/listen.mode = 0600/' /etc/php5/fpm/pool.d/www.conf
#
#these settings are fairly conservative and can probably be increased without things melting
  sed -i 's/pm.max_children = 5/pm.max_children = 12/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.start_servers = 2/pm.start_servers = 4/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 2/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 4/' /etc/php5/fpm/pool.d/www.conf
  sed -i 's/;pm.max_requests = 500/pm.max_requests = 500/' /etc/php5/fpm/pool.d/www.conf
#

  
#Engage.
  /etc/init.d/php5-fpm start

}


#################################
#  nginx      #
#################################

function lemp_nginx {

#install it.
  aptitude install -y nginx-full

#Make it so.
  /etc/init.d/nginx start

}