LEMP installation script and lemp script

Source: Internet
Author: User

LEMP installation script and lemp script

#! /Bin/bash
# LEMP Server
Umount/dev/cdrom
Mount/dev/cdrom/media
IOS = "/etc/yum. repos. d/rhel-debuginfo.repo"
If [$? = 0]; then
Sed-I '3d '$ IOS
Sed-I '3i baseurl = file: // media/Server' $ IOS
Sed-I '4d '$ IOS
Sed-I '4i enabled = 1' $ IOS
Else
Echo "Yum is no"
Sleep 3
Fi
Yum-y install pcre-devel zilb-devel
If [$? = 0]; then
Echo "YUM repository configuration successful"
Sleep 3
Else
Exit
Echo "YUM repository configuration error"
Cat $ IOS
Fi
Useradd-M-s/sbin/nologin nginx
Mkdir/ruanjianbao
Cd/ruanjianbao
Rz
Sleep 3
If [$? = 0]; then
Echo "Nginx package uploaded"
Else
Echo "Nginx package not uploaded"
Fi
Cd/ruanjianbao
Tar zxf nginx-1.0.8.tar.gz
Cd nginx-1.0.8
./Configure -- prefix =/usr/local/nginx -- user = nginx -- group = nginx -- with-http_stub_status_module; make install
If [$? = 0]; then
Echo "Nginx correct configuration compilation and installation"
Else
Echo "Nginx misconfiguration compilation and installation"
Exit
Sleep 3
Fi
Ulimit-n 65535
Echo "ulimit-n 65535">/etc/rc. d/rc. local
Ln-s/usr/local/nginx/sbin/nginx/usr/local/sbin/
Ls-l/usr/local/sbin/nginx
Sleep 3
Cd ~
Nginx # Start Nginx
If [$? = 0]; then
Netstat-anpt | grep "nginx" # Check whether the Nginx service is enabled
Sleep 3
Else
Echo "NO !, Nginx Server is down"
Fi
Killall-s HUP nginx # smoothly restart nginx (or killall-1 nginx)
Killall-s QUIT nginx # Stop nginx normally (or killall-3 nginx)
# Killall-s USR1 nginx logs can be split
# Killall-s USR2 NGINX smooth upgrade executable (online upgrade)
Echo '#! /Bin/bash
# Chkconfig: 2345 99 20
# Description: Nginx Server Control Script
PROG = "/usr/local/nginx/sbin/nginx"
PIDF = "/usr/local/nginx/logs/nginx. pid"
Case "$1" in
Start)
$ PROG
;;
Stop)
Kill-s QUIT $ (cat $ PIDF)
;;
Restart)
$0 stop
$0 start
;;
Reload)
Kill-s HUP $ (cat $ PIDF)
;;
*)
Echo "Usage: $0 (start | stop | restart | reload )"
Exit 1
Esac
Exit 0'>/etc/init. d/nginx
If [$? = 0]; then
Echo "Nginx execution program, added"
Chmod + x/etc/init. d/nginx
Chkconfig -- add nginx
Chkconfig nginx on
Chkconfig nginx -- list
Sleep 3
Else
Exit
Sleep 3
Echo "Nginx execution program, failed to add"
Fi
Nginx = "/usr/local/nginx/conf/nginx. conf"
Sed-I's/# user/'$ Nginx
Sed-I '/nobody/s/nobody/nginx/' $ Nginx
Sed-I '6d '$ Nginx # enable notice-level logs based on your preferences (the log fields are divided into debug \ info \ notice \ warn \ error \ crit)
Sed-I '6i error_log logs/error. log notice; '$ Nginx # This log is not necessarily in the sixth line, so cat/usr/local/nginx/conf/nginx is required. if the configuration in conf is not in this line, do not execute this script language.
Sed-I '13i use epoll; '$ Nginx # use epoll to customize the nginx working mode.
Sed-I '/worker_connectons/s/1024/20000/' $ Nginx # This section defines the maximum number of connections for each nginx process. The default value is 1024, if the modification can be performed based on the CPU kernel of the server, for example, if the CPU is 4 cores, then 1024*4, and so on.
Sed-I '/# log_format/s/# //' $ Nginx
Sed-I '/$ status $ body_bytes_sent/s/# //' $ Nginx
Sed-I '/$ http_user_agent/s/# //' $ Nginx
Sed-I '/# access_log/s/# //' $ Nginx # support for File Sending and downloading
Sed-I '/server_name/s/localhost/www.cheshi.com/' $ Nginx # define the Domain Name of the web Server
Sed-I's/koi8-r/UTF-8/'$ Nginx # define Character Set
Sed-I '/# charset/s/# //' $ Nginx
Sed-I '48i location ~ /Status {'$ Nginx # The access location is/status
Sed-I '49i stub_status on; '$ Nginx # enable the statistics Status
Sed-I '50i access_log off; '$ Nginx # disable location Logging
Sed-I '51i} '$ Nginx
If [$? = 0]; then
Echo "Nginx configuration file succeeded"
Service nginx restart
Sleep 3
Else
Nginx-t
Service nginx restart
Fi
Echo ***************************** install Mysql ******** *************************'
Cd/ruanjianbao/
Rz
If [$? = 0]; then
Echo "Mysql uploaded successfully"
Sleep 3
Else
Sleep 3
Echo "Mysql Upload Failed"
Fi
Cd/ruanjianbao
Tar zxf mysql-5.1.55.tar.gz
Cd mysql-5.1.55
./Configure -- prefix =/usr/local/mysql -- with-charset = utf8 -- with-collation = utf8_general_ci -- with-extra-charsets = gbk, gb2312; make install
If [$? = 0]; then
Echo "Mysql correct configuration, compilation, and installation"
Else
Echo "Mysql misconfiguration compilation and installation"
Sleep 3
Exit
Fi
Cd/ruanjianbao/mysql-5.1.55
Cp support-files/my-medium.cnf/etc/my. cnf
Cp support-files/mysql. server/etc/init. d/mysqld
Chmod + x/etc/init. d/mysqld
Ln-s/usr/local/mysql/bin/*/usr/local/bin/
Ln-s/usr/local/mysql/lib/mysql/*/usr/lib
Ln-s/usr/local/mysql/include/mysql/*/usr/include/
Useradd-M-u 27-s/sbin/nologin mysql
Cd/usr/local/mysql/bin/
./Mysql_install_db -- user = mysql
If [$? = 0]; then
Sleep 3
Echo "Mysql formatted successfully"
Else
Echo "Mysql formatting failed"
Sleep 3
Exit
Fi
Chown-R root: mysql/usr/local/mysql/
Chown-R mysql/usr/local/mysql/var/
/Etc/init. d/mysqld restart
If [$? = 0]; then
Echo "Mysql is up"
Sleep 3
Else
Echo "Mysql is down"
Sleep 3
Exit
Fi
Echo ****************************** install Php ******* ********************'
Cd/ruanjianbao/
Rz
If [$? = 0]; then
Echo "Php uploaded successfully"
Sleep 3
Else
Exit
Sleep 3
Echo "Php Upload Failed"
Fi
Cd/ruanjianbao/
Tar zxf php-5.3.6.tar.gz
Cd php-5.3.6
. /Configure -- prefix =/usr/local/php5 -- with-gd -- with-zlib -- with-mysql =/usr/local/mysql -- with-config-file-path =/ usr/local/php5 -- enable-mbstring -- enable-fpm; make; make install
If [$? = 0]; then
Echo "Php correct configuration, compilation, and installation"
Sleep 3
Else
Echo "Php misconfiguration compilation and installation"
Exit
Sleep 3
Fi
Cd/ruanjianbao/php-5.3.6
Cp php. ini-development/usr/local/php5/php. ini
Ln-s/usr/local/php5/bin/*/usr/local/bin/
Ln-s/usr/local/php5/sbin/*/usr/local/sbin/
Echo ************************************ Installation zendGuardLoader optimization module **************************'
Cd/ruanjianbao/
Rz
If [$? = 0]; then
Echo "ZendGuardLoader uploaded successfully"
Sleep 3
Else
Echo "ZendGuardLoader Upload Failed"
Sleep 3
Exit
Fi
Tar zxf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
Cd ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/
Cp ZendGuardLoader. so/usr/local/php5/lib/php/
Echo 'zend _ extension =/usr/local/php5/lib/php/ZendGuardLoader. so
Zend_loader.enable = 1'>/usr/local/php5/php. ini
Cd/usr/local/php5/etc/
Cp php-fpm.conf.default php-fpm.conf
PHP = "php-fpm.conf"
Sed-I's/; pid/'$ PHP # confirm the pid File Location
Sed-I '/user =/s/nobody/nginx/' $ PHP # program user
Sed-I '/group =/s/nobody/nginx/' $ PHP # Program group
Sed-I's/; pm. start/pm. start/'$ PHP # Number of processes temporarily started
Sed-I's/; pm. min/pm. min/'$ PHP # check the number of idle Processes
Sed-I's/; pm. max_spare_server/pm. max_spare_server/'$ PHP # A maximum of idle Processes
/Usr/local/sbin/php-fpm
Netstat-anpt | grep php-fpm
Sleep 3
If [$? = 0]; then
Echo "php configuration file OK"
Else
Echo "php configuration file NO"
Sleep 3
Exit
Fi
Echo '#! /Bin/bash
# Chkconfig: 2345 99 20
# Description: Nginx Server Control Script
PROG = "/usr/local/nginx/sbin/nginx"
PIDF = "/usr/local/nginx/logs/nginx. pid"
PROG_FPM = "/usr/local/sbin/php-fpm"
PIDF_FPM = "/usr/local/php5/var/run/php-fpm.pid"
Case "$1" in
Start)
$ PROG
$ PROG_FPM
;;
Stop)
Kill-s QUIT $ (cat $ PIDF)
Kill-s QUIT $ (cat $ PIDF_FPM)
;;
Restart)
$0 stop
$0 start
;;
Reload)
Kill-s HUP $ (cat $ PIDF)
;;
*)
Echo "Usage: $0 (start | stop | restart | reload )"
Exit 1
Esac
Exit 0'>/etc/init. d/nginx
Mkdir-p/var/www/goleg
Nginx = '/usr/local/nginx/conf/nginx. conf'
Sed-I '/server_name/s/www.cheshi.com/www.goleg.com/' $ nginx
Sed-I '/root/s # html #/var/www/goleg #' $ nginx
Sed-I '48d' $ nginx
Sed-I '49d' $ nginx
Sed-I '50d' $ nginx
Sed-I '51d '$ nginx
Sed-I '/index/s/index.html index. php/' $ nginx
Sed-I '48i error_page 500 502 503 x.html; '$ nginx
Sed-I '49i location =/50x.html {'$ nginx
Sed-I '50i root html; '$ nginx
Sed-I '51i} '$ nginx
Sed-I '52i location ~ \. Php $ {'$ nginx
Sed-I '53i root/var/www/goleg; '$ nginx
Sed-I '54i fastcgi_pass 127.0.0.1: 9000; '$ nginx
Sed-I '55i fastcgi_index index. php; '$ nginx
Sed-I '56i include fastcgi. conf; '$ nginx
Sed-I '57i} '$ nginx
Sed-I '58i} '$ nginx
Sed-I '59, $ d' $ nginx
Nginx-t
Slepp 5
Service nginx restart
If [$? = 0]; then
Echo "Nginx supports PHP configuration successful"
Sleep 3
Elsecd
Echo "Nginx support for PHP configuration failed"
Sleep 3
Exit
If
Mkdir-p/var/www/goleg
Echo ************************ Add a website module *********** ****************'
Cd/ruanjianbao/
Rz
If [$? = 0]; then
Echo "The module has been uploaded"
Sleep 3
Else
Echo "failed to upload the module"
Sleep 3
Exit
Fi
Cd/ruanjianbao/
Tar jxf SKYUC_3.2.2_Free_For_PHP5.3.tar.bz2
Mv SKYUC_3.2.2_Free_For_PHP5.3/wwwroot/var/www/goleg/skyuc
Mysqladmin-uroot password lei1998
Echo 'create DATABASE goleg;
GRANT all ON goleg. * TO 'lei' @ 'localhost' identified by '000000'; '>/root/mysql
Mysql-uroot-plei1998 </root/mysql
If [$? = 0]; then
Echo "Mysql dtatbase, GRANT is OK"
Rm-rf/root/mysql
Echo "Mysql dtatbase, GRANT is no"
Sleep 3
Exit
Fi
Cd/var/www/goleg/skyuc/
Chown-R nginx: nginx admincp/data/templates/upload/
If [$? = 0]; then
Echo "LEMP Server is OK! "
Sleep 3
Else
Echo "LEMP Server in ON! "
Sleep 3
Exit
Fi
### Manually clear 55 p and all characters below
#2015.06.20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.