The previous period of time to maintain the server, need to install the LNMP environment, so I tidied up a bit, as a script, recorded.
#!/bin/sh#copyright (c) 2010-2015 redapple ([email protected]) #install lnmp # version 0.1.1#date 20140813#------------Add Yum source------------------------rpm -ivh http:// pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpmrpm -ivh http:// download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm#------------ Installing GCC------------------------yum install gcc-c++ gcc ncurses-devel wget openssl openssl-devel zlib-devel -y#--------------time Synchronization--------------------ntpdate tiger.sina.com.cnhwclock -w#----------------Download and install Pcre------------------[ ! -f Pcre-8.35.tar.gz ] && wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ pcre-8.35.tar.gztar xf pcre-8.35.tar.gz cd pcre-8.35./configure --prefix=/usr/ local/pcremake && make install#----------------Download AnnInstall Nginx------------------cd  ... groupadd -r nginxuseradd -r -g nginx -s /bin/false -m nginx[ ! -f nginx-1.6.1.tar.gz ] && wget http://nginx.org/download/ Nginx-1.6.1.tar.gztar -xf nginx-1.6.1.tar.gzcd nginx-1.6.1./configure --prefix =/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/ access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/ nginx.lock --user=nginx --group=nginx --with-pcre --with-http_ssl_module --with-http_flv_module --with-http_ssl_ module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/ nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ -- http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgimake && make install#----------------set Nginx boot----------------cd cp nginx /etc/rc.d/init.dchmod +x /etc/rc.d/init.d/nginxchkconfig nginx on#----- -----------Download and install MySQL------------------yum install cmake ncurses-devel -ygroupadd Mysqluseradd -g mysql mysql -s /bin/falsemkdir -p /data/mysqlchown -r mysql:mysql /data/mysql[ ! -f mysql-5.5.38.tar.gz ] && wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.38.tar.gztar xf Mysql-5.5.38.tar.gz cd mysql-5.5.38cmake -dcmake_install_prefix=/usr/local/mysql -dmysql_datadir=/data/mysql -dsysconfdir=/etc -ddefault_charset=utf8 -ddefault_collation=utf8_unicode_ci -dwith_readline=1 -dwith_ssl=system -dwith_embedded_server= 1 -denabled_local_infile=1 -ddefault_collation=utf8_general_ci -dwith_myisam_storage_engine=1 -dwith_innobase_storage_engine=1 -dwith_debug=0make && make install[ -f /etc/my.cnf ] && rm -rf /etc/my.cnfcp support-files/my-medium.cnf /etc/my.cnfsed -i ' s#max_allowed_packet = 1m#max_allowed_packet = 16m# ' /etc/my.cnf./scripts/mysql_install_db --user=mysql --datadir=/data/mysql[ -f / etc/init.d/mysqld ] && rm -rf /etc/init.d/mysqldcp ./support-files/ mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldsed -i ' 46s#basedir=# basedir=/usr/local/mysql# ' /etc/init.d/mysqldsed -i ' 47s#datadir= #datadir =/data/mysql# ' /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld onecho "path= $PATH:/usr/local/mysql/bin" >> /etc/profile ln -s /usr/local/mysql/lib/mysql /usr/lib/mysqlln -s /usr/ local/mysql/include/mysql /usr/include/mysqlservice mysqld startps -ef |grep mysqld#----------------Download and install FreeType------------------cd .. [ ! -f freetype-2.5.3.tar.gz ] && wget http:// Download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gztar -zxvf freetype-2.5.3.tar.gzcd freetype-2.5.3./configure --prefix=/usr/local/freetypemake && make install#- ---------------Download and install Libmcrypt------------------cd . [ ! -f libmcrypt-2.5.7.tar.gz ] && wget ftp://mcrypt.hellug.gr/pub/ Crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gztar -zxvf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7./configure make && make install#----------------Download and install jpegsrc.v9------------------cd .. [ ! -f jpegsrc.v9a.tar.gz ] && wget http://www.ijg.org/files/ jpegsrc.v9a.tar.gztar -xf jpegsrc.v9a.tar.gzcd jpeg-9a./configure --prefix=/usr/local/ jpegmake && make install#----------------Download and install PHP------------------cd Yum install -y libcurl bzip2-devel bzip2 libxml2-devel curl curl-devel gd libpng zlib #---Want the compiled PHP to support MCrypt, Mhash extensions, and libevent---------#yum install Libmcrypt libmcrypt-devel mhash mhash-devel mcrypt[ ! -f php-5.5.15.tar.gz ] && wget http://cn2.php.net/distributions/php-5.5.15.tar.gztar xf Php-5.5.15.tar.gzcd php-5.5.15./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-xml --enable-mbstring -- enable-bcmath --enable-soap --enable-shmop --enable-sysvsem --enable-pcntl -- enable-zip --enable-gd-native-ttf --with-mysqli=/usr/local/mysql/bin/mysql_config -- with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir -- with-zlib-dir --with-libxml-dir=/usr --with-mhash --with-mcrypt --with-gettext --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --with-xmlrpc --without-pear make && make installcp ./ php.ini-production /usr/local/php/etc/php.inised -i ' s#;d ate.timezone = #date. TimeZone = prc# ' /etc/php.inised -i ' s#expose_php = on#expose_php = off# ' /etc/php.ini#---------------- Configuring PHP-FPM------------------cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/ php-fpm.confsed -i ' s#user = nobody#user = nginx# ' /usr/local/php/etc/ php-fpm.confsed -i ' s#group = nobody#group = nginx# ' /usr/local/php/etc/ php-fpm.confsed -i ' s#pm.max_children = 5#pm.max_children = 150# ' /usr/ local/php/etc/php-fpm.confsed -i ' s#pm.start_servers = 2#pm.start_servers = 8# ' /usr/local/php/etc/php-fpm.confsed -i ' S#pm.min_spare_servers = 1#pm.min_spare_ servers = 5# ' /usr/local/php/etc/php-fpm.confsed -i ' s#pm.max_spare_servers = 3#pm.max_spare_servers = 10# ' /usr/local/php/etc/php-fpm.confsed -i ' s#;p ID = run/php-fpm.pid#pid = run/php-fpm.pid# ' /usr/local/php/etc/php-fpm.confcp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpmchmod +x /etc/rc.d/init.d/php-fpmchkconfig --add php-fpmchkconfig php-fpm on#-------------- --Configuration Nginx support PHP------------------cd Cat nginx.conf >/etc/nginx/nginx.confmkdir -p /etc/nginx/vhostscp default.conf /etc/nginx/vhosts#----------------Check php and php-fpm------------------Service php-fpm startservice nginx startps -ef | grep nginxps aux | grep php-fpm#------- ---------The test page of the new index.php------------------cat > /usr/html/index.php << eof< Phpphpinfo ();? >EOFecho "=============lnmp install ok !!!! ============"
This article is from the "Red apple" blog, please be sure to keep this source http://262242.blog.51cto.com/252242/1572004
LNMP install shell script in one click