This script has been used for more than a year on the production server, and this script advocates simplicity and beauty, and requires only one script to automatically configure LNMP on any server that has a network.
In the script execution directory, the script builds the packages directory to store the software needed for LNMP. You can delete the directory after you install it.
You need to enter Y confirmation once the script is running.
#/bash
# Author:coralzd Powered by www.freebsdsystem.org
# Written by Coralzd 2011.05.05
# version 0.1.3 build 20110505
Nginx_dir= "/usr/local/nginx"
Php52_dir= "/usr/local/php52"
Mysql_dir= "/usr/local/mysql"
function init ()
{
Lang=c
Yum-y install wget gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2 -devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl Curl-devel E2fspro GS e2fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Ients openldap-servers
Read-p "Now,will download nginxphp software ... Y|y: "nginxphp
Case "$nginxphp" in
Y|y)
Echo-n "Starting download nginx_php ..."
Cat > List << "EOF" &&
Nginx-1.0.0.tar.gz
Php-5.2.17.tar.gz
Php-5.2.17-fpm-0.5.14.diff.gz
Libiconv-1.13.1.tar.gz
Libmcrypt-2.5.8.tar.gz
Mcrypt-2.6.8.tar.gz
Memcache-2.2.5.tgz
Mhash-0.9.9.9.tar.gz
Mysql-5.1.52.tar.gz
Pcre-8.10.tar.gz
eaccelerator-0.9.6.1.tar.bz2
Pdo_mysql-1.0.2.tgz
Libunwind-0.99.tar.gz
ImageMagick.tar.gz
Imagick-2.3.0.tgz
Google-perftools-1.6.tar.gz
Fcgi.conf
Ini
Nginx.conf
Php-fpm.conf
Eof
mkdir Packages
For i in ' Cat list '
Todo
If [-S packages/$i]; Then
echo "$i [found]"
Else
echo "Error: $i not found!!! Download Now ... "
wget http://www.freebsdsystem.org/linux/nginx-php/$i-P packages/
Fi
Done
;;
*)
Echo-n "Exit Install script"
Exit 0
;;
Esac
Groupadd www && useradd www-s/sbin/nologin-g www
Groupadd MySQL && useradd mysql-s/sbin/nologin-g MySQL
echo "www and mysql user && group create!"
/BIN/RM-RF List
Echo-e "All of installed sucussful!"
}
function Is_version ()
{
If [' uname-m ' = ' x86_64 '];then
Tar zxf libunwind-0.99.tar.gz
Tar zxvf libunwind-0.99.tar.gz
CD libunwind-0.99/
Cflags=-fpic./configure
Make Cflags=-fpic
Make Cflags=-fpic Install
Cd.. /
Else
echo "Your system is 32bit, not install Libunwind lib!"
Fi
}
function Ins_nginx ()
{
CD Packages
Is_version
Tar zxf google-perftools-1.6.tar.gz
CD google-perftools-1.6
./configure
Make
Make install
Cd..
Tar zxf pcre-8.10.tar.gz
CD pcre-*
./configure
Make
Make install
Cd..
Tar zxf nginx-1.0.0.tar.gz
CD nginx-1.0.0
./configure--prefix=${nginx_dir}--with-google_perftools_module--user=www--group=www--with-http_stub_status_ Module--with-http_flv_module--with-http_ssl_module
Make && make install
Cd..
Rm-rf/usr/local/nginx/conf/nginx.conf
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
CP nginx.conf/usr/local/nginx/conf/
CP fcgi.conf/usr/local/nginx/conf/
echo "Nginx installed sucussfully!"
}
function Ins_mysql-server ()
{
CD packages/
Tar zxf mysql-5.1.52.tar.gz
CD mysql-5.1.52
Chost= "X86_64-pc-linux-gnu"
Cflags= "-march=nocona-o2-pipe"
cxxflags= "${cflags}"
./configure "--prefix=${mysql_dir}" "--with-server-suffix=-dzwww" "--with-mysqld-user=mysql" "--without-debug" "-- With-charset=utf8 "--with-extra-charsets=all" "--with-pthread" "--with-big-tables" "--enable-thread-safe-client" " --enable-assembler ""--with-readline ""--with-ssl ""--enable-local-infile ""--WITH-PLUGINS=PARTITION,MYISAMMRG "" Without-ndb-debug "
Make && make install
CP Support-*/mysql.server/etc/init.d/mysqld
Cd/usr/local/mysql
Chown-r Mysql:mysql.
RM-RF Sql-bench Mysql-test
echo "MySQL server 5.1.52 installed successfully!"
}
function Ins_mysql-client ()
{
CD packages/
Tar zxf mysql-5.1.52.tar.gz
CD mysql-5.1.52
Chost= "X86_64-pc-linux-gnu"
Cflags= "-march=nocona-o2-pipe"
cxxflags= "${cflags}"
./configure "--prefix=${mysql_dir}" "--with-mysqld-user=mysql" "--without-debug" "--with-charset=utf8" "-- With-extra-charsets=all ""--with-pthread ""--with-big-tables ""--enable-thread-safe-client ""--enable-assembler ""- -with-readline ""--with-ssl ""--enable-local-infile ""--without-server "
Make && make install
Cd/usr/local/mysql
Chown-r Mysql:mysql.
RM-RF Sql-bench Mysql-test
echo "MySQL client 5.1.52 installed successfully!"
}
function ins_php52 ()
{
CD packages/
Tar zxf libiconv-1.13.1.tar.gz
CD LIBICONV-1.13.1/
./configure--prefix=/usr/local
Make
Make install
Cd.. /
Tar zxf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8/
./configure
Make
Make install
/sbin/ldconfig
CD libltdl/
./configure--enable-ltdl-install
Make
Make install
Cd.. /.. /
Tar zxf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9/
./configure
Make
Make install
Cd.. /
Ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la
Ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so
Ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4
Ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8
Ln-s/USR/LOCAL/LIB/LIBMHASH.A/USR/LIB/LIBMHASH.A
Ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la
Ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so
Ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2
Ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Tar zxf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8/
/sbin/ldconfig
./configure
Make
Make install
Cd.. /
Tar zxf php-5.2.17.tar.gz
GZIP-CD php-5.2.17-fpm-0.5.14.diff.gz | Patch-d PHP-5.2.17-P1
CD php-5.2.17/
./configure--prefix=${php52_dir}--with-config-file-path=${php52_dir}/etc--with-mysql=${mysql_dir}--with-mysqli =${mysql_dir}/bin/mysql_config--with-iconv-dir=/usr/local--with-freetype-dir--with-jpeg-dir--with-png-dir-- With-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-discard-path--enable-safe-mode-- Enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers-- Enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--enable-mbstring--with-mcrypt-- Enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-ldap-- With-xmlrpc--enable-zip--enable-soap
Make zend_extra_libs= '-liconv '
Make install
Cd..
CP php.ini/usr/local/php52/etc/
CP php-fpm.conf/usr/local/php52/etc/
echo "/usr/local/mysql/lib/mysql" >>/etc/ld.so.conf.d/mysql_lib.conf
/sbin/ldconfig
echo "Php52 installed successfully!"
}
function Ins_php52-ext ()
{
CD packages/
Tar zxf memcache-2.2.5.tgz
CD memcache-2.2.5/
${php52_dir}/bin/phpize
./configure--with-php-config=${php52_dir}/bin/php-config
Make
Make install
Cd.. /
Tar jxf eaccelerator-0.9.6.1.tar.bz2
CD EACCELERATOR-0.9.6.1/
${php52_dir}/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=${php52_dir}/bin/php-config
Make
Make install
Cd.. /
Tar zxf pdo_mysql-1.0.2.tgz
CD PDO_MYSQL-1.0.2/
${php52_dir}/bin/phpize
./configure--with-php-config=${php52_dir}/bin/php-config--with-pdo-mysql=${mysql_dir}
Make
Make install
Cd.. /
Tar zxf ImageMagick.tar.gz
CD imagemagick-6.5.1-2/
./configure
Make
Make install
Cd.. /
Tar zxf imagick-2.3.0.tgz
CD imagick-2.3.0/
${php52_dir}/bin/phpize
./configure--with-php-config=${php52_dir}/bin/php-config
Make
Make install
Cd.. /
echo "php52 extension installed successfully!"
}
Case is in
Init
Init
;;
Ins_mysql-server)
Ins_mysql-server
;;
Ins_mysql-client)
Ins_mysql-client
;;
Ins_nginx)
Ins_nginx
;;
INS_PHP52)
Ins_php52
;;
Ins_php52-ext)
Ins_php52-ext
;;
*)
echo "Usage: ' basename $ ' {init|ins_mysql-server|ins_mysql-client|ins_php52|ins_php52-ext|ins_mysql} '
;;
Esac