#!/bin/bash #Authors are from JC #From the region BeiJing-China #Contact:285221465@qq.com # Source function library. . /etc/rc.d/init.d/functions cd $shell shell=/shell/script if [ -d /shell/script ];then action "shell安装目录已存在:" /bin/true else mkdir -p $shell >/dev/null fi function main_menu() { echo;echo; echo "----------------------------------Linux+Nginx+1.2+MySQL5.5+PHP5.2+Memcache---------------------------------------------" current_date=`date +%Y%m%d-%H:%M:%S` dis_manumenu="《线上服务器${ip}安装服务菜单》" cat <<EOF 当前时间为:$current_date ============================================================== $dis_manumenu ============================================================== -->[lnmp服务器自动化版本程序 ]:<-- **1)安装lnmp服务(make && make install) **2)查看lnmp启动服务端口(tcp:80,3306,9000) **3)启动lnmp服务端口 **4)关闭lnmp服务端口 **5)回滚之前操作(即恢复lnmp安装前的状态) **6)备份lnmp环境 **7)还原lnmp环境 ############################################################### =============================================================== EOF } main_menu read -p "请选择: " num ##############编译前的依赖环境安装############################ case $num in 1) echo "-------------------------------------现在开始安装lnmp+memcache环境----------------------------------------------------------" sleep 3 cd /etc/yum.repos.d wget http://mirrors.163.com/.help/CentOS-Base-163.repo yum -y install ntp rsync sudo /usr/sbin/ntpdate pool.ntp.org yum -y install 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 e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make libXp* gcc-c++ autoconf ncurses ncurses-devel echo 'export LC_ALL=C'>> /etc/profile source /etc/profile #cd $shell #[ ! -f cmake-2.8.4.tar.gz ] && \ #wget -P/shell/script/ -c http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz && echo "cmake-2.8.4.tar.gz download is OK" # cd $shell # tar zxvf cmake-2.8.4.tar.gz # cd cmake-2.8.4 # ./configure # gmake # gmake install sleep 3 cd $shell [ ! -f bison-2.5.tar.gz ] && \ wget -P /shell/script/ -c http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz && echo "bison-2.5.tar.gz download is OK" sleep 2 cd $shell tar zxvf bison-2.5.tar.gz cd bison-2.5 ./configure && make && make install sleep 3 ##############编译安装MySQL5.1.56版本数据库################### yum -y install cmake cd $shell [ ! -f mysql-5.5.19.tar.gz ] && \ wget -P/shell/script/ -c http://down1.chinaunix.net/distfiles/mysql-5.5.19.tar.gz && echo "mysql-5.5.19.tar.gz download is OK" cd $shell groupadd mysql useradd -s /sbin/nologin -g mysql -M mysql tar zxvf mysql-5.5.19.tar.gz cd $shell/mysql-5.5.19 /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STOPAGE_ENGINE=1 -DWITH_BLACKHOLE_STOPAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP-PORT=3306 make && make install chmod +w /usr/local/mysql chown -R mysql:mysql /usr/local/mysql ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16 mkdir -p /var/mysql/ mkdir -p /var/mysql/data/ mkdir -p /var/mysql/log/ chown -R mysql:mysql /var/mysql/ cd support-files/ cp my-large.cnf /var/mysql/my.cnf cp mysql.server /etc/init.d/mysqld /usr/local/mysql/scripts/mysql_install_db --defaults-file=/var/mysql/my.cnf --basedir=/usr/local/mysql/ --datadir=/var/mysql/data/ --user=mysql chmod 700 /etc/init.d/mysqld echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile source /etc/profile ln -s /usr/local/mysql/bin/* /usr/bin/ sed -i '46s#basedir=#basedir=/usr/local/mysql/#' /etc/init.d/mysqld sed -i '47s#datadir=#datadir=/var/mysql/data/#' /etc/init.d/mysqld chkconfig --add mysqld chkconfig --level 345 mysqld on /etc/init.d/mysqld restart action "mysql5.5.19版本安装完成" /bin/true action "mysql5.5.19版本安装完成" /bin/true sleep 3 ############编译安装libiconv1.13.1版本############################################# cd $shell [ ! -f libiconv-1.13.1.tar.gz ] && \ wget -P $shell -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz echo "libiconv-1.13.1.tar.gz download is OK" sleep 3 cd $shell tar zxvf libiconv-1.13.1.tar.gz cd libiconv-1.13.1 ./configure --prefix=/usr/local && make && make install action "libiconv1.13.1版本安装完成" /bin/true action "libiconv1.13.1版本安装完成" /bin/true sleep 3 cd $shell [ ! -f libmcrypt-2.5.8.tar.gz ] && \ wget -P $shell -c http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz echo "libmcrypt-2.5.8.tar.gz download is OK" sleep 3 cd $shell tar zxvf 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 action "libmcrypt2.5.8版本安装完成" /bin/true action "libmcrypt2.5.8版本安装完成" /bin/true sleep 3 ############编译安装mhash0.9.9.9.9版本############################################# cd $shell [ ! -f mhash-0.9.9.9.tar.gz ] && \ wget -P /shell/script/ -c "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0" echo "mhash-0.9.9.9.tar.gz download is OK" sleep 3 cd $shell tar zxvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/ ./configure && make && make install 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 action "mhash0.9.9.9版本安装完成" /bin/true action "mhash0.9.9.9版本安装完成" /bin/true #################编译安装mcrypt2.6.8版本############################################## cd $shell [ ! -f mcrypt-2.6.8.tar.gz ] && \ wget -P /shell/script -c "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0" echo "mcrypt-2.6.8.tar.gz download is OK" sleep 3 cd $shell tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make && make install sleep 3 ################编译安装php5.2.17 or patch php5.2.17#################################### cd $shell [ ! -f php-5.2.17.tar.gz ] && \ wget -P /shell/script -c http://www.php.net/get/php-5.2.17.tar.gz/from/this/mirror echo "php-5.2.17.tar.gz download is OK" sleep 3 cd $shell [ ! -f php-5.2.17-fpm-0.5.14.diff.gz ] && \ wget -P /shell/script -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz echo "php-5.2.17-fpm-0.5.14.diff.gz download is OK" sleep 3 cd $shell tar -zxvf 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=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/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 --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap make ZEND_EXTRA_LIBS='-liconv' make install cp php.ini-dist /usr/local/php/etc/php.ini ############编译安装memcache2.2.5版本########################### yum -y install libevent libevent-devel cd $shell [ ! -f memcached-1.2.5.tar.gz ] && \ wget -P /shell/script -c http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz echo "memcache-1.2.5.tar.gz download is OK" sleep 3 cd $shell tar zxvf memcached-1.2.5.tar.gz cd memcached-1.2.5 ./configure --prefix=/usr/local/memcache make && make install cd $shell [ ! -f memcache-2.2.5.tgz ] && \ wget -P /shell/script -c http://pecl.php.net/get/memcache-2.2.5.tgz echo "memcache-2.2.5.tgz download is OK" sleep 3 cd $shell tar zxvf memcache-2.2.5.tgz cd memcache-2.2.5/ /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install ##########编译安装eaccelerator0.9.6.1版本######################## cd $shell [ ! -f eaccelerator-0.9.6.1.tar.bz2 ] && \ wget -P /shell/script -c http://sourceforge.net/projects/eaccelerator/files/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2 echo "eaccelerator-0.9.6.1.tar.bz2 download is OK" sleep 3 cd $shell tar -xjvf eaccelerator-0.9.6.1.tar.bz2 cd eaccelerator-0.9.6.1 /usr/local/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config make && make install ##########编译安装PDO_MYSQL1.0.2版本############################# cd $shell [ ! -f PDO_MYSQL-1.0.2.tgz ] && \ wget -P /shell/script -c http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz echo "PDO_MYSQL-1.0.2.tgz download is OK" sleep 3 cd $shell tar zxvf PDO_MYSQL-1.0.2.tgz cd PDO_MYSQL-1.0.2/ rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql make && make install #########编译安装ImageMagick6.7.1.0版本########################## cd $shell [ ! -f ImageMagick.tar.gz ] && \ wget -P /shell/script -c http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz echo "ImageMagick.tar.gz download is OK" sleep 3 cd $shell tar -zxvf ImageMagick.tar.gz cd ImageMagick-6.5.1-2 ./configure && make && make install #######编译安装imagick2.3.0版本################################# cd $shell [ ! -f imagick-2.3.0.tgz ] && \ wget -P /shell/script -c http://pecl.php.net/get/imagick-2.3.0.tgz echo "imagick-2.3.0.tgz download is OK" sleep 3 cd $shell tar zxvf imagick-2.3.0.tgz cd imagick-2.3.0 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/php/etc/php.ini sed -i "s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g" /usr/local/php/etc/php.ini mkdir -p /usr/local/eaccelerator_cache sed -i '1290a [eaccelerator]' /usr/local/php/etc/php.ini sed -i '1291a zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"' /usr/local/php/etc/php.ini sed -i '1292a eaccelerator.shm_size="64"' /usr/local/php/etc/php.ini sed -i '1293a eaccelerator.cache_dir="/usr/local/eaccelerator_cache"' /usr/local/php/etc/php.ini sed -i '1294a eaccelerator.enable="1"' /usr/local/php/etc/php.ini sed -i '1295a eaccelerator.optimizer="1"' /usr/local/php/etc/php.ini sed -i '1296a eaccelerator.check_mtime="1"' /usr/local/php/etc/php.ini sed -i '1297a eaccelerator.debug="0"' /usr/local/php/etc/php.ini sed -i '1298a eaccelerator.filter=""' /usr/local/php/etc/php.ini sed -i '1299a eaccelerator.shm_max="0"' /usr/local/php/etc/php.ini sed -i '1300a eaccelerator.shm_ttl="3600"' /usr/local/php/etc/php.ini sed -i '1301a eaccelerator.shm_prune_period="3600"' /usr/local/php/etc/php.ini sed -i '1302a seaccelerator.shm_only="0"' /usr/local/php/etc/php.ini sed -i '1303a eaccelerator.compress="1"' /usr/local/php/etc/php.ini sed -i '1304a eaccelerator.compress_level="9"' /usr/local/php/etc/php.ini /usr/sbin/groupadd www /usr/sbin/useradd -g www www mkdir -p /var/www/wiki mkdir -p /var/www/memcache mkdir -p /var/www/phpmyadmin chmod +w /var/www/memcache chmod +w /var/www/phpmyadmin chmod +w /var/www/wiki chown -R www:www /var/www/wiki chown -R www:www /var/www/memcache chown -R www:www /var/www/phpmyadmin sed -i '58s#<!--##g' /usr/local/php/etc/php-fpm.conf sed -i '58s#-->##g' /usr/local/php/etc/php-fpm.conf sed -i '59s#<!--##g' /usr/local/php/etc/php-fpm.conf sed -i '59s#-->##g' /usr/local/php/etc/php-fpm.conf sed -i '63s#<!--##g' /usr/local/php/etc/php-fpm.conf sed -i '63s#-->##g' /usr/local/php/etc/php-fpm.conf sed -i '66s#<!--##g' /usr/local/php/etc/php-fpm.conf sed -i '66s#-->##g' /usr/local/php/etc/php-fpm.conf sed -i '63s#nobody#www#g' /usr/local/php/etc/php-fpm.conf sed -i '66s#nobody#www#g' /usr/local/php/etc/php-fpm.conf sed -i '79s#5#128#g' /usr/local/php/etc/php-fpm.conf sed -i '113s#1024#20480#g' /usr/local/php/etc/php-fpm.conf sed -i '132s#500#1024#g' /usr/local/php/etc/php-fpm.conf ulimit -SHn 65535 /usr/local/php/sbin/php-fpm start ###############编译安装pcre8.31版本 or Nginx1.21版本########################## cd $shell [ ! -f pcre-8.31.tar.gz ] && \ wget -P /shell/script -c ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz echo "pcre-8.31.tar.gz download is OK" sleep 3 cd $shell tar -zxvf pcre-8.31.tar.gz cd pcre-8.31 ./configure && make && make install cd $shell [ ! -f nginx-1.2.1.tar.gz ] && \ wget -P /shell/script -c http://www.nginx.org/download/nginx-1.2.1.tar.gz echo "nginx-1.2.1.tar.gz download is OK" sleep 3 cd $shell tar -zxvf nginx-1.2.1.tar.gz cd nginx-1.2.1 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make && make install mkdir -p /app/logs chmod +w /app/logs chown -R www:www /app/logs mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.jc mv /opt/jc/nginx.conf /usr/local/nginx/conf/ mv /opt/jc/fcgi.conf /usr/local/nginx/conf/ ulimit -SHn 65535 /usr/local/nginx/sbin/nginx echo '/usr/local/nginx/sbin/nginx' >>/etc/rc.local echo '/usr/local/php/sbin/php-fpm start' >>/etc/rc.local echo '/usr/local/mysql/bin/mysql start' >>/etc/rc.local sed -i '33a net.ipv4.tcp_max_syn_backlog = 65536' /etc/sysctl.conf sed -i '34a net.core.netdev_max_backlog = 32768' /etc/sysctl.conf sed -i '35a net.core.somaxconn = 32768' /etc/sysctl.conf sed -i '36a net.core.somaxconn = 32768' /etc/sysctl.conf sed -i '37a net.core.wmem_default = 8388608' /etc/sysctl.conf sed -i '38a net.core.rmem_default = 8388608' /etc/sysctl.conf sed -i '39a net.core.rmem_max = 16777216' /etc/sysctl.conf sed -i '40a net.core.wmem_max = 16777216' /etc/sysctl.conf sed -i '41a net.ipv4.tcp_timestamps = 0' /etc/sysctl.conf sed -i '42a net.ipv4.tcp_synack_retries = 2' /etc/sysctl.conf sed -i '43a net.ipv4.tcp_syn_retries = 2' /etc/sysctl.conf sed -i '44a net.ipv4.tcp_tw_recycle = 1' /etc/sysctl.conf sed -i '45a net.ipv4.tcp_tw_reuse = 1' /etc/sysctl.conf sed -i '46a net.ipv4.tcp_mem = 94500000 915000000 927000000' /etc/sysctl.conf sed -i '47a net.ipv4.tcp_max_orphans = 3276800' /etc/sysctl.conf sed -i '48a net.ipv4.ip_local_port_range = 1024 65535' /etc/sysctl.conf ##################安装memcache管理页面#################################### cd $shell [ ! -f memcachephp.zip ] && \ wget -P /shell/script -c http://livebookmark.net/memcachephp/memcachephp.zip echo "memcachephp.zip download is OK" sleep 3 cd $shell unzip -o memcachephp.zip sed -i '22s/memcache/test/g' $shell/memcache.php sed -i '23s/password/123456/g' $shell/memcache.php sed -i '28s/mymemcache-server1/10.0.19.23/g' $shell/memcache.php sed -i '29s/mymemcache-server2/10.0.19.23/g' $shell/memcache.php sed -i '29s/11211/11212/g' $shell/memcache.php cp -rf $shell/memcache.php /var/www/memcache chmod 755 /var/www/memcache/memcache.php /sbin/sysctl -p cd /opt/jc/ cp -rf nginx /etc/init.d/ cp -rf /usr/local/php/sbin/php-fpm /etc/init.d/ dos2unix /etc/init.d/nginx dos2unix /etc/init.d/php-fpm chmod 777 /etc/init.d/nginx chmod 777 /etc/init.d/php-fpm ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 /sbin/ldconfig ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/ iptables -X iptables -F iptables -Z /sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 3306 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 9000 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 11211 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 11212 -j ACCEPT ;; 2) action "正在查看lnmp and Memcache端口信息..............................." /bin/true sleep 3 echo "--------------------------------------lnmp端口列表--------------------------------------------------------" netstat -lntp|grep 80 netstat -lntp|grep 3306 netstat -lntp|grep 9000 netstat -lntp|grep 11211 netstat -lntp|grep 11212 echo "--------------------------------------lnmp端口列表---------------------------------------------------------" ;; 3) echo "正在启动,请稍等....................." sleep 3 nohup /etc/init.d/nginx restart >/dev/null nohup /etc/init.d/mysqld restart >/dev/null nohup /etc/init.d/php-fpm restart >/dev/null /usr/local/memcache/bin/memcached -d -m 1024 -u root -t 64 -r -c 16382 -p 11211 /usr/local/memcache/bin/memcached -d -m 1024 -u root -t 64 -r -c 16382 -p 11212 action "lnmp服务器已经开启" /bin/true sleep 2 action "memcache服务器已经开启" /bin/true ;; 4) echo "正在关闭,请稍等....................." sleep 3 nohup /etc/init.d/nginx stop >/dev/null nohup /etc/init.d/mysqld stop >/dev/null nohup /etc/init.d/php-fpm stop >/dev/null nohup killall -9 memcached 2>/dev/null action "lnmp服务器已经关闭" /bin/true sleep 2 action "memcache服务器已经关闭" /bin/true ;; 5) echo "-------------------------------------------先关闭lnmp环境----------------------------------------------------" sleep 2 nohup /etc/init.d/nginx stop >/dev/null nohup /etc/init.d/mysqld stop >/dev/null nohup /etc/init.d/php-fpm stop >/dev/null sleep 2 echo "------------------------------------------已经关闭lnmp环境成功-----------------------------------------------" sleep 2 echo "现在开始回滚lnmp编译前的环境" sleep 3 for server in nginx mysql php do rm -rf /usr/local/$server done for mysql in mysql.sock do rm -rf /tmp/$mysql done for servers in nginx mysqld php-fpm do rm -f /etc/init.d/$servers done find /var/lock/subsys -name nginx|xargs rm -f find /etc/rc.d/init.d/ -name nginx|xargs rm -f for a in mysql do rm -rf /var/$a done find /usr/bin/ -name mysql|xargs rm -f rm -rf /var/lock/subsys/mysql rm -rf /usr/lib/php sleep 3 rm -rf /usr/local/memcache rm -rf /var/www/memcache action "lnmp回滚已经成功" /bin/true sleep 2 action "lnmp回滚已经成功" /bin/true ;; 6) action "现在开始备份lnmp环境" /bin/true sleep 3 echo "-------------------------------现在开始备份Nginx服务器--------------------------------------" cd $shell mkdir -p $shell/bak cd $shell/bak zip -r nginx.zip /usr/local/nginx zip -r nginxinit.zip /etc/init.d/nginx action "Nginx服务器备份已经完成" /bin/true sleep 3 echo "-----------------------------现在开始备份MySQL数据库--------------------------------------------------" sleep 3 cd $shell/bak zip -r mysql.zip /usr/local/mysql zip -r mysqllib.zip /var/mysql zip -r mysqlinit.zip /etc/init.d/mysqld action "MySQL数据库备份已经完成" /bin/true sleep 3 echo "--------------------------------现在开始备份php服务器--------------------------------------------------" sleep 3 cd $shell/bak zip -r php.zip /usr/local/php zip -r phplib.zip /usr/lib/php zip -r phpinit.zip /etc/init.d/php-fpm action "PHP服务器备份已经完成" /bin/true sleep 3 echo "--------------------------------现在开始备份Memcache缓存服务器-----------------------------------------" sleep 3 cd $shell/bak zip -r memcache.zip /usr/local/memcache zip -r memcache_jiankong.zip /var/www/memcache action "Memcache缓存服务器备份已经完成" /bin/true sleep 3 echo "--------------------------------lnmp服务器+Memcache服务器已经备份完成----------------------------------" sleep 3 action "lnmp备份完成" /bin/true sleep 2 action "Memcache备份完成" /bin/true sleep 3 ;; 7) echo "----------------------------------开始还原lnmp服务 and Memcache缓存服务器-------------------------------" sleep 3 echo "----------------------------------开始还原Nginx服务器----------------------------------------------------" sleep 3 cd $shell/bak unzip -o nginx.zip mkdir -p /usr/local/nginx cp -rf usr/local/nginx/* /usr/local/nginx/ rm -rf /shell/script/bak/usr/ cd $shell/bak unzip -o nginxinit.zip cp -rf etc/init.d/nginx /etc/init.d/ chmod 755 /etc/init.d/nginx action "Nginx服务器还原完成" /bin/true sleep 3 action "Nginx服务器还原完成" /bin/true sleep 3 echo "------------------------------------开始还原MySQL数据库-------------------------------------------------" sleep 3 cd $shell/bak unzip -o mysql.zip mkdir -p /usr/local/mysql cp -rf usr/local/mysql/* /usr/local/mysql/ chown -R mysql.mysql /usr/local/mysql rm -rf /shell/script/bak/usr/ cd $shell/bak unzip -o mysqllib.zip mkdir -p /var/mysql cp -rf var/mysql/* /var/mysql/ rm -rf /shell/script/bak/var/ cd $shell/bak unzip -o mysqlinit.zip cp -rp etc/init.d/mysqld /etc/init.d/ chmod 755 /etc/init.d/mysqld chown -R mysql.mysql /var/mysql/ action "MySQL数据库还原完成" /bin/true sleep 3 action "MySQL数据库还原完成" /bin/true sleep 3 echo "----------------------------------------开始还原PHP服务器--------------------------------------------------" sleep 3 cd $shell/bak unzip -o php.zip mkdir -p /usr/local/php cp -rf usr/local/php/* /usr/local/php/ rm -rf /shell/script/bak/usr/ cd $shell/bak unzip -o phplib.zip mkdir -p /usr/lib/php cp -rf usr/lib/php/* /usr/lib/php/ cd $shell/bak unzip -o phpinit.zip cp -rf etc/init.d/php-fpm /etc/init.d/ chmod 755 /etc/init.d/php-fpm action "PHP服务器还原完成" /bin/true sleep 3 action "PHP服务器还原完成" /bin/true sleep 3 echo "-----------------------------------------开始还原Memcache缓存服务器------------------------------------------" sleep 3 cd $shell/bak unzip -o memcache.zip mkdir -p /usr/local/memcache/ cp -rf usr/local/memcache/* /usr/local/memcache/ mkdir -p /var/www/memcache unzip -o memcache_jiankong.zip cp -rf var/www/memcache/* /var/www/memcache/ chmod -R 755 /var/www/memcache action "Memcache缓存服务器还原完成" /bin/true sleep 3 action "Memcache缓存服务器还原完成" /bin/true sleep 3 echo "-----------------------------------------lnmp服务器和Memcache缓存服务器还原已经完成---------------------------------------------------------" sleep 3 ;; *) action "安装程序已经退出..................................................." /bin/true exit 1 esac
自动安装lnmp环境
精选 转载文章标签 linux lnmp 自动安装 脚本 文章分类 服务器
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
LNMP环境自动化安装脚本
一、脚本的环境介绍此脚本运行在RHEL(Ce。
mysql php PHP