#######################################################################################
#!bin/sh #
#AUTHOR: Yuhonggang #
#TIME: 2014/10/13 17:26 #
#DESCRIBE: The script is used-create the LNMP just by One Touch #
#VERSION: V1.0 #
#######################################################################################
Tools=/home/yuhonggang/tools
App=/application
###### #INSTALL nginx#################################################################
Echo-e "\033[32;45;5m###### #INSTALL nginx###################################\033[0m"
Sleep 2
If [-D $TOOLS];then
CD $TOOLS
Else
Mkdir-p $TOOLS && CD $TOOLS
Fi
If [-D $APP];then
echo "$APP is Exsit"
Else
mkdir $APP && echo "$APP has ben created"
Fi
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
wget http://fossies.org/linux/misc/pcre-8.36.tar.gz
Yum install gcc-c++ openssl*-y
Tar zxf pcre-8.36.tar.gz
CD pcre-8.36
./configure
Make && make install
If [$? = 0]
Then
echo "Pcre Install is successful"
Else
echo "Pcre install is fail" && exit 2
Sleep 5
Fi
CD $TOOLS
Sleep 5
wget http://nginx.org/download/nginx-1.2.9.tar.gz
Useradd nginx-s/sbin/nologin-m
Tar XF nginx-1.2.9.tar.gz
CD nginx-1.2.9
./configure--user=nginx--group=nginx--prefix= $APP/nginx-1.2.9--with-http_stub_status_module--with-http_ssl_ Module
Make && make install
If [$? = 0]
Then
echo "Nginx Install is successful"
Else
echo "Nginx install is fail" && exit 2
Sleep 5
Fi
CD $TOOLS
Ln-s $APP/nginx-1.2.9 $APP/nginx
echo "/usr/local/lib/" >>/etc/ld.so.conf
Ldconfig
$APP/nginx/sbin/nginx-t
$APP/nginx/sbin/nginx
Lsof-i tcp:80
If [$? = 0]
Then
echo "Nginx Install all are successful"
Else
echo "Nginx Install all is fail" && exit 2
Sleep 5
Fi
CD $TOOLS
###### #INSTALL mysql################################################################
Echo-e "\033[32;45;5m###### #INSTALL mysql###################################\033[0m"
Sleep 5
CD $TOOLS
Sleep 3
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
Tar XF cmake-2.8.8.tar.gz
CD cmake-2.8.8
./configure
Gmake && gmake Install
If [$? = 0]
Then
echo "Nginx CMake is successful"
Else
echo "Nginx CMake is fail" && exit 2
Sleep 5
Fi
CD $TOOLS
Useradd mysql-s/sbin/nologin-m
Yum Install Ncurses-devel-y
Sleep 2
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz
Tar XF mysql-5.6.12.tar.gz
CD mysql-5.6.12
CMake. -dcmake_install_prefix= $APP/mysql-5.6.12 \
-dmysql_datadir= $APP/mysql-5.6.12/data \
-dmysql_unix_addr= $APP/mysql-5.6.12/tmp/mysql.sock \
-DDEFAULT_CHARSET=GBK \
-DDEFAULT_COLLATION=GBK_CHINESE_CI \
-denabled_local_infile=on \
-dwith_innobase_storage_engine=1 \
-dwith_federated_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwithout_example_storage_engine=1
Make && make install
If [$? = 0]
Then
echo "MySQL install is successful"
Else
echo "MySQL install is fail" && exit 2
Fi
Sleep 5
Ln-s $APP/mysql-5.6.12/$APP/mysql
CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
Echo ' Export path=/application/mysql/bin: $PATH ' >>/etc/profile
Sleep 2
. /etc/profile
Mkdir-p $APP/mysql/data/
Chown-r Mysql.mysql $APP/mysql/*
Chmod-r 1777/tmp
Sleep 2
$APP/mysql/scripts/mysql_install_db--basedir= $APP/mysql--datadir= $APP/mysql/data/--user=mysql
CP Support-files/mysql.server/etc/init.d/mysqld
chmod 700/etc/init.d/mysqld
/etc/init.d/mysqld start
Chkconfig mysqld on
If [$? = 0]
Then
echo "MySQL Install all are successful"
Else
echo "MySQL Install all is fail" && exit 2
Fi
Sleep 5
###### #INSTALL php##################################################################
Echo-e "\033[32;45;5m###### #INSTALL php###################################\033[0m"
Sleep 5
CD $TOOLS
Yum install zlib libxml libjpeg freetype libpng gd Curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel L Ibpng-devel Gd-devel Curl-devel libxslt-devel-y
Sleep 2
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
Tar XF libiconv-1.14.tar.gz
CD libiconv-1.14
./configure--prefix=/usr/local/libiconv
Make && make install
Sleep 2
CD $TOOLS
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
Tar zxf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make
Make install
Sleep 2
/sbin/ldconfig
CD libltdl/
./configure--enable-ltdl-install
Make
Make install
Sleep 2
CD $TOOLS
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
Tar zxf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9/
./configure
Make
Make install
Sleep 2
CD $TOOLS
Rm-f/usr/lib64/libmcrypt.*
Rm-f/usr/lib64/libmhash*
Ln-s/usr/local/lib64/libmcrypt.la/usr/lib64/libmcrypt.la
Ln-s/usr/local/lib64/libmcrypt.so/usr/lib64/libmcrypt.so
Ln-s/usr/local/lib64/libmcrypt.so.4/usr/lib64/libmcrypt.so.4
Ln-s/usr/local/lib64/libmcrypt.so.4.4.8/usr/lib64/libmcrypt.so.4.4.8
Ln-s/USR/LOCAL/LIB64/LIBMHASH.A/USR/LIB64/LIBMHASH.A
Ln-s/usr/local/lib64/libmhash.la/usr/lib64/libmhash.la
Ln-s/usr/local/lib64/libmhash.so/usr/lib64/libmhash.so
Ln-s/usr/local/lib64/libmhash.so.2/usr/lib64/libmhash.so.2
Ln-s/usr/local/lib64/libmhash.so.2.0.1/usr/lib64/libmhash.so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
Yum Install libxslt libxslt-devel-y
Sleep 2
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz
Tar zxf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8/
/sbin/ldconfig
./configure
Make && make install
Sleep 2
CD $TOOLS
Ln-s $APP/mysql/lib/libmysqlclient.so.18/usr/lib
Ldconfig
wget http://cn2.php.net/distributions/php-5.3.29.tar.gz
Tar XF php-5.3.29.tar.gz
CD php-5.3.29
./configure--prefix= $APP/php5.3.29--with-mysql= $APP/mysql--with-iconv-dir=/usr/local/libiconv-- With-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath-- Enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl-- With-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf-- With-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap-- Enable-short-tags--enable-zend-multibyte--enable-static--with-xsl--with-fpm-user=nginx--with-fpm-group=nginx-- Enable-ftp
CP ext/phar/phar.php Ext/phar/phar.phar
Make && make install
Sleep 2
Ln-s $APP/php5.3.29/$APP/php
CD $TOOLS/php-5.3.29
CP php.ini-production $APP/php/lib/php.ini
MV $APP/php5.3.29/etc/php-fpm.conf.default $APP/php5.3.29/etc/php-fpm.conf
$APP/PHP/SBIN/PHP-FPM
If [$? = 0]
Then
echo "PHP Install is successful"
Else
echo "PHP install is fail" && exit 2
Fi
Sleep 5
###### #INSTALL phpcachemodule#################################################################
Echo-e "\033[32;45;5m###### #INSTALL phpcachemodule###################################\033[0m"
Sleep 5
echo ' Export lc_all=c ' >>/etc/profile
Tail-1/etc/profile
. /etc/profile
Yum Install Perl-devel-y
CD $TOOLS
#install Eaccelerator
Sleep 2
wget http://soft.kwx.gd/module/eaccelerator-0.9.6.tar.bz2
Tar jxf eaccelerator-0.9.6.tar.bz2
CD eaccelerator-0.9.6
$APP/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config= $APP/php/bin/php-config
Make && make install
[$?-ne 0] && {
echo "Install Eaccelerator failed!"
Exit 2
}
Cd.. /
Sleep 2
#install Memcache
wget http://pecl.php.net/get/memcache-2.2.5.tgz
Tar zxf memcache-2.2.5.tgz
CD memcache-2.2.5
$APP/php/bin/phpize
./configure--with-php-config= $APP/php/bin/php-config
Make && make install
[$?-ne 0] && {
echo "Install Memcache failed!"
Exit 2
}
Cd.. /
Sleep 2
#install Pdo_mysql
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
Tar zxf pdo_mysql-1.0.2.tgz
CD pdo_mysql-1.0.2
$APP/php/bin/phpize
./configure--with-php-config= $APP/php/bin/php-config--with-pdo-mysql= $APP/mysql
Make && make install
[$?-ne 0] && {
echo "Install Pdo_mysql failed!"
Exit 2
}
Cd.. /
#install ImageMagick
Sleep 5
wget http://down1.chinaunix.net/distfiles/ImageMagick-6.5.1-0.tar.bz2
Tar jxf imagemagick-6.5.1-0.tar.bz2
CD imagemagick-6.5.1-0
./configure
Make
Make install
[$?-ne 0] && {
echo "Install ImageMagick failed!"
Exit 2
}
Cd.. /
Sleep 2
#install Imagick PHP
wget http://pecl.php.net/get/imagick-2.3.0.tgz
Tar zxf imagick-2.3.0.tgz
CD imagick-2.3.0
$APP/php/bin/phpize
./configure--with-php-config= $APP/php/bin/php-config
Make
Make install
[$?-ne 0] && {
echo "Install Imagick php failed!"
Exit 2
}
Cd.. /
Sleep 2
CD $APP/php/lib/
CP php.ini php.ini_$ (date +%f)
Sed-i ' s#; Extension_dir = "./" #extension_dir = "/application/php/lib/php/extensions/no-debug-non-zts-20090626/" #g ' php.ini
Cat >> $APP/php/lib/php.ini<<eof
Extension = memcache.so
Extension = pdo_mysql.so
Extension = imagick.so
Eof
#config Eaccelerator
Mkdir-p/tmp/eaccelerator
Chown-r Nginx.nginx/tmp/eaccelerator
Cat >> $APP/php/lib/php.ini<<eof
[Eaccelerator]
Extension = eaccelerator.so
Eaccelerator.shm_size= "64"
Eaccelerator.cache_dir= "/tmp/eaccelerator"
eaccelerator.enable= "1"
Eaccelerator.optimizer= "1"
Eaccelerator.check_mtime= "1"
eaccelerator.debug= "0"
Eaccelerator.filter= ""
eaccelerator.shm_max= "0"
Eaccelerator.shm_ttl= "3600"
eaccelerator.shm_prune_period= "3600"
eaccelerator.shm_only= "0"
eaccelerator.compress= "1"
Eaccelerator.compress_level= "9"
Eof
Sleep 1
echo "====================================="
$APP/php/bin/php-v
[$?-eq 0] && echo "Config PHP Cache module sucessful" | | Exit 2
echo "====================================="
One-click Lnmp Script &&php expansion module installation