One-click installation package for lamp or LNMP

Source: Internet
Author: User
Tags bz2 exit fpm install php openssl sleep snmp openldap

There are a lot of lnmp/lamp on the web. The installation of a script, the compilation of installation parameters to modify the script, this script integrates lamp and LNMP, in any network of Red Hat or CentOS server automatically configured LNMP or lamp, The user can customize the compilation parameters, or you can compile the installation using the default parameters of this script. You can also install MySQL, nginx, Apache, PHP separately.

How to: Save a file with the following code, such as inst_lanmp.sh upload to the server for execution.

This script is passed under the CentOS 6.0 X864 environment: The following effects are used:

The code is as follows:

#!/bin/bash #set-X #date: 2013-01-06 #Description: One-click installation LNMP Environment or LAMP environment #Version: 0.1 #Author: Wolf #定义命令搜索路 Path Path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export Path src_dir=/usr/src nginx_dir=/u Sr/local/nginx mysql_dir=/usr/local/mysql php_dir=/usr/local/php Libmcrypt_dir=/usr/local/libmcypt apache_dir=/usr /local/apache #关闭SELiunx echo "Disabled SELinux" if [-s/etc/selinux/config] then Sed-i ' s/selinux=enforcing/   
Selinux=disabled/g '/etc/selinux/config fi/usr/sbin/setenforce 0 # Check If user is root if [' $UID '-ne 0] 
Then printf "error:you must is root to run this script!\n" Exit 1 fi #检查需要的软件包是否存在, if not downloaded. 
    DOWNLOAD_SRC () {CD $src _dir if [s libiconv-1.13.1.tar.gz] then echo "Libiconv-1.13.1.tar.gz found" else echo "libiconv-1.13.1.tar.gz not found. Download new ... "Wget http://mozbuildtools.googlecode.com/files/libiconv-1.13.1.tar.gz fi if[-S mhash-0.9.9.9.tar.gz] then echo "mhash-0.9.9.9.tar.gz found" else echo "mhash-0.9.9.9.tar.gz not found. Download new ... "wget http://acelnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz fi if [s Mysql-5.5.25a.tar. GZ] then echo "mysql-5.5.25a.tar.gz found" else echo "mysql-5.5.25a.tar.gz not found. Download new ... "wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz fi if [s php-5 .3.13.tar.gz] Then echo "php-5.3.13.tar.gz found" else echo "php-5.3.13.tar.gz not found. Download new ... "wget http://us1.php.net/distributions/php-5.3.13.tar.gz fi if [s google-perftools-1.6.t AR.GZ] then echo "google-perftools-1.6.tar.gz found" else echo "google-perftools-1.6.tar.gz not found. Download new ... "wget http://gperftools.googlecode.com/files/google-perftools-1.6.tar.gz fi if [s cmake-2. 8.4.TAR.GZ] then echo "cmake-2.8.4.tar.gz found ..." Else echO "cmake-2.8.4.tar.gz not found.  Download new ... "wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz fi if [s libmcrypt-2.5.7.tar.gz ] then echo "libmcrypt-2.5.7.tar.gz found" else echo "libmcrypt-2.5.7.tar.gz not found. 
      
Download new ... "Wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/Production/libmcrypt-2.5.7.tar.gz fi If [s memcache-2.2.5.tgz] then echo "memcache-2.2.5.tgz found" else echo "memcache-2.2.5.tgz not fo und. Download new ... "wget http://vps.googlecode.com/files/memcache-2.2.5.tgz fi if [s eaccelerator-0.9.5.3. TAR.BZ2] then echo "eaccelerator-0.9.5.3.tar.bz2 found" else echo "eaccelerator-0.9.5.3.tar.bz2 not found.
    Download new ... "  
    wget http://autosetup1.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2 fi if [s ImageMagick.tar.gz] Then echo "ImageMagick.tar.gz found" else echo "ImageMagick.tar.gz not found.
    Download NRW. " wget http:www.imagemagick.org/download/ImageMagick.tar.gz fi if [s imagick-2.3.0.tgz] then echo imagick-2.3. 0.tgz found "else echo" imagick-2.3.0.tgz not found. Download new "wget http://lnmpp.googlecode.com/files/imagick-2.3.0.tgz fi}" #初始化服务器 Init_server () {for SRC in dialog ntp vim-enhanced vixie-cron gcc gcc-c++ gcc-g77 Flex Bison autoconf automake glibc glibc-devel glib2 glib2-d Evel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel F Ontconfig-devel freetype-devel libxpm-devel gettext-devel Curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn Libidn-devel OpenSSL openssl-devel openldap openldap-devel net-snmp net-snmp-devel nss_ldap openldap-clients Libtidy libtidy-devel wget libc-client libc-client-devel openldap-servers pcre do pcre-devel yum-y $src D  
     
  One ln-s/usr/lib64/libc-client.so*/usr/lib/ln-s/usr/lib64/libldap*/usr/lib}   
#先检测apache是否已经安装, if it is not installed, install the Apache CD $src _dir Inst_apache () {if [-D $apache _dir] then echo "A Pache is installed ' exit 1 Else CD $SRC _dir echo ' Apache not install.
    Install run ... "If [-s httpd-2.2.24.tar.gz] then echo" httpd-2.2.24.tar.gz found. " else echo "httpd-2.2.24.tar.gz not found. 
             
        Download new ... "Wget http://mirror.apache-kr.org/httpd/httpd-2.2.24.tar.gz fi If ["$apache _mo" = "] then echo" You did not enter the compilation parameters, compile with the default parameters ... "Tar zxvf httpd-2.2.24.ta r.gz CD $src _dir/httpd-2.2.24/configure--prefix=/usr/local/apache3--enable-so--enable-rewrite Ble-mods-shared=most--with-mpm=worker make && make install CD. /Else tar zxvf httpd-2.2.24.tar.gz cd $src _dir/httpd-2.2.24 $apache _mo Make & & Make install fi fi} #先检测mysQL is installed, if it is installed, no longer installed, if not installed MySQL Inst_mysql () {useradd-s/sbin/nologin-m mysql tar zxvf cmake-2.8.4.tar.gz CD $ src_dir/cmake-2.8.4./configure && make && make install if [-D $mysql _dir] then echo " MySQL is installed "else if [" $mysql _mo "=" "] then echo" You did not enter the MySQL compilation parameters, use this script default parameter to compile ....
            .." echo "MySQL not install.  
            Install run ... "CD $src _dir tar zxvf mysql-5.5.25a.tar.gz cd mysql-5.5.25a CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-dsysconfdir=/etc-dwith_innobase_ Storage_engine=1-dwith_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dwith_federated_storage_ Engine=1-dwith_partition_storage_engine=1-dmysql_tcp_port=3306-denabled_local_infile=1-dwith_ssl=yes-dextra_ Charsets=all-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_readline=on Gmake &&Make install else echo ' MySQL not install. 
            Install run ... "CD $src _dir tar zxvf mysql-5.5.25a.tar.gz cd mysql-5.5.25a $mysql fi fi if [-F/ECT/MY.CNF] then CD $src _dir/mysql-5.5.25a echo "MySQL Co Nfig file my.cnf found. Backup my.cnf to My.cnf.bak "MV/ETC/MY.CNF/ETC/MY.CNF.BAK/BIN/CP support-files/my-small.cnf/etc/my.c 
        NF/BIN/CP support-files/mysql.server/etc/rc.d/init.d/mysqld chmod 755/etc/rc.d/init.d/mysqld Chown mysql:mysql/usr/local/mysql-r fi/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql/--dat adir=/usr/local/mysql/data/--user=mysql--defaults-file=/etc/my.cnf chown Mysql:mysql/usr/local/mysql-r} i  
        Nst_libmcypt () {if [-D $libmcrypt _dir] then echo "Libmcrypt is installed." Else CD $SRC _dir Tar zxvf libmcrypt-2.5.7.tar.gz CD Libmcrypt-2.5.7./configure--prefix=/usr/local/libmcypt && make && make Install/sbin/ldconfi G CD libltdl/./configure--enable-ltdl-install make make install fi CD $SRC _ Dir tar zxf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/./configure make make install Ln-s R/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} #先检测PHP是否已经编译安装, install the PHP inst_php_apache () {CD $src _dir tar zxf If the installation is no longer installed, if it is not installed libiconv-1.13.1  
    . tar.gz cd libiconv-1.13.1/./configure--prefix=/usr/local make make install CD $src _dir if [-D $php _dir] Then echo "PHP is installed" else if ["$php _mo" = ""] then echo "You did not enter the compile installation parameters and compile the installation using the default parameters of this script ...
        .." echo "PHP not install. Install run ... "CD $src _dir tar zxvf php-5.3.13.tar.gz cd php-5.3.13./configure- prefix=/usr/local/php--with-config-file-path=/usr/local/php/lib--with-mysql=/usr/local/mysql/bin/mysql_config- -with-enable-sysvsem--with-apxs2=/usr/local/apache/bin/apxs--with-openssl--with-zlib--with-bz2--with-curl-- WITH-LIBXML-DIR=/USR--with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir--enable-gd-native-ttf-- Enable-gd-jis-conv--without-iconv--with-ldap--with-mcrypt=/usr/local/libmcypt--with-zlib-dir--WITH-SNMP-- Enable-zip--with-curlwrappers--with-imap--with-kerberos--with-imap-ssl--with-freetype-dir Local/mysql make && make install CP Php.ini-development/usr/local/php/lib/php.ini C
        P/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf else echo uses the parameters you entered to compile the installation ... echo "PHP not install. Install run ... "CD $SRC _dir tar ZXVF php-5.3.13.tar.gz CD php-5.3.13 $php _mo make && make install CP php.in I-development/usr/local/php/lib/php.ini cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.co nf fi fi} inst_php () {CD $src _dir tar zxf libiconv-1.13.1.tar.gz cd libiconv-1.13.1/./configure--prefix=
        /usr/local/libiconv make make install CD $src _dir if [-D $php _dir) then echo "PHP is installed" else If ["$php _mo" = "] then echo" You did not enter the PHP installation compilation parameters and will compile with the default parameters of this script ... "Sleep 5 echo" Please choose Optional installation method, 1, installation and Nginx combined with the use of php,2, installation and Apache in combination with PHP ... "read-p" Please enter a number [1 |          
                    2]: "Php_num case $php _num in 1) echo" is installing and nginx in combination with PHP ... Sleep 5 echo ' PHP not install.  
       Install run ... "CD $src _dir tar zxvf php-5.3.13.tar.gz             CD php-5.3.13./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/ph P/lib--with-mysql=/usr/local/mysql/bin/mysql_config--with-enable-sysvsem--enable-fpm--with-openssl--with-zlib- -with-bz2--with-curl--with-libxml-dir=/usr--with-gd--with-jpeg-dir--with-png-dir-- Enable-gd-native-ttf--enable-gd-jis-conv--with-iconv=/use/local/libiconv--with-ldap--with-mcrypt=/usr/local/ Libmcypt--with-zlib-dir--with-snmp--enable-zip--with-curlwrappers--with-imap-  With-freetype-dir--with-mysql=/usr/local/mysql make && make install CP Php.ini-development/usr/local/php/lib/php.ini Cp/usr/local/php/etc/php-fpm.conf.default/usr/loca 
                l/php/etc/php-fpm.conf;; 2) echo "is installing PHP in conjunction with Apache ..." Sleep 5/configure--p Refix=/usr/local/php--with-config-file-path=/usr/local/php/lib--with-mysql=/usr/local/mysql/bin/mysql_config-- With-enable-sysvsem--with-apxs2=/usr/local/apache/bin/apxs--with-openssl--with-zlib--with-bz2--with-curl-- WITH-LIBXML-DIR=/USR--with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir--enable-gd-native-ttf-- Enable-gd-jis-conv--without-iconv--with-ldap--with-mcrypt=/usr/local/libmcypt--with-zlib-dir--WITH-SNMP-- Enable-zip--with-curlwrappers--with-imap--with-kerberos--with-imap-ssl--with-freetype-dir Local/mysql make && make install CP php.ini-development/usr/local/php/l 
                Ib/php.ini cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf 
                ;; *) echo "Please enter a number [1 | 
            2]: "Esac else echo" you entered the PHP compile installation parameters, using the parameters you entered to compile ... "Sleep 5 echo "PHP not install. Install run ... "CD $src _dir tar zxvf php-5.3.13.tar.gz CD php-5.3.13 $  
            Php_mo make && make install CP Php.ini-development/usr/local/php/lib/php.ini cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf fi fi} inst_php_nginx (  
{CD $src _dir tar zxf libiconv-1.13.1.tar.gz cd libiconv-1.13.1/./configure--prefix=/usr/local make make install 
            CD $SRC _dir if [D-$php _dir) then echo "PHP is installed" else if ["$php _mo" = "] Then echo "You did not enter the compile installation parameters, use the default parameters of this script to install" echo "PHP not install.  
            Install run ... "CD $src _dir tar zxvf php-5.3.13.tar.gz cd php-5.3.13 ./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/lib--with-mysql=/usr/local/mysql/bin/ Mysql_config--with-enable-sysvsem--enable-fpm--with-openssl--with-zLib--with-bz2--with-curl--with-libxml-dir=/usr--with-gd--with-jpeg-dir--with-png-dir-- Enable-gd-native-ttf--enable-gd-jis-conv--without-iconv--with-ldap--with-mcrypt=/usr/local/libmcypt-- With-zlib-dir--with-snmp--enable-zip--with-curlwrappers--with-imap--with-kerberos-- With-freetype-dir--with-mysql=/usr/local/mysql make && make install CP Php.ini-develo 
        Pment/usr/local/php/lib/php.ini cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf else echo "You entered the mysql compilation parameter and compiled it using the parameters you entered ..." echo "PHP not install. Install run ... "Sleep 5 cd php-5.3.13 $php _mo make && make INS Tall CP Php.ini-development/usr/local/php/lib/php.ini Cp/usr/local/php/etc/php-fpm.conf.defaul t/usr/local/php/etc/php-fpm.conf fi fi} #安装PHP扩展 inst_PHP_EX () {CD $src _dir tar zxf memcache-2.2.5.tgz cd memcache-2.2.5/${php_dir}/bin/phpize./configure--with-php -config=${php_dir}/bin/php-config make make install CD. /tar jxf eaccelerator-0.9.5.3.tar.bz2 cd eaccelerator-0.9.5.3 ${php_dir}/bin/phpize./configure--enable-e accelerator=shared--with-eaccelerator-shared-memory--with-php-config=${php_dir}/bin/php-config make make install C D $src _dir tar zxf ImageMagick.tar.gz cd imagemagick-6.8.1-9/./configure make make install CD. /tar zxf imagick-2.3.0.tgz cd imagick-2.3.0/${php_dir}/bin/phpize./configure--with-php-config=${php_dir}/  
Bin/php-config make make install CD.  
echo "PHP extension installed successfully!"} #安装nginx Inst_nginx () {if [s nginx-1.3.10.tar.gz] then echo nginx-1.3.10.tar.gz found. "Else echo" ngi Nx-1.3.10.tar.gz not found. 
    Download new ... "Wget http://www.nginx.org/download/nginx-1.3.10.tar.gz fi  
CD $src _dir tar zxf google-perftools-1.6.tar.gz cd google-perftools*./configure make make install CD $SRC _dir If [-D $nginx _dir] then echo "Nginx is installed" else if ["$nginx _mo" = ""] then E  
        Cho "You did not enter setup parameters, compile the installation using the default parameters of this script" CD $src _dir tar zxvf nginx-1.3.10.tar.gz cd nginx-1.3.10 ./configure--prefix=/usr/local/nginx--with-http_ssl_module--with-http_stub_status_module--with-http_gzip_ Static_module--with-http_stub_status_module made && make install else echo "you entered the installation parameters, using your input 
        Parameters for installation ... "CD $src _dir tar zxvf nginx-1.3.10.tar.gz cd nginx-1.3.10 $nginx _mo Made && make install fi fi} #生成一个PHP启动脚本, you can use service PHPD start | Restart | Stop | Show start, restart, shutdown, view run status phpd () {cat <<eof >>phpd #!/bin/bash #Author: Wolf #Date: 2013-01-03 # #chkc Onfig:-#processname: Php php=/USR/LOCAL/PHP/SBIN/PHP-FPM conf=/usr/local/php/etc/php-fpm.conf case, in Start echo-n   
      "Starting PHP" $php echo "done";;   
        Stop) echo-n "stopping php" killall-9 php-fpm echo "done";;   
       Restart) $ stop $ start;;   
       Show) ps-aux|grep PHP;;   
*) Echo-n "Usage: $ {start|restart|reload|stop|test|show}";; Esac EOF if [-F/USR/SRC/PHPD] THEN/BIN/CP/USR/SRC/PHPD/ETC/RC.D/INIT.D/PHPD chmod +x/etc/rc.d/init.d/p HPD fi} #生成nginx启动脚本, you can use service Nginxd start | Restart | Stop | Reload | Test | 
Show restarts, shuts down, starts >, tests configuration Files, views status, and reloads.  Nginxd () {cat <<eof >>/usr/src/nginxd #!/bin/bash #Author: Wolf #Date: 2013-01-03 # #chkconfig:-85   #description: Nginx is a world Wide Web server.
#processname: Nginx Nginx=/usr/local/nginx/sbin/nginx conf=/usr/local/nginx/conf/nginx.conf case $ in S   
      Tart) echo-n "Starting Nginx" $nginx-C $conf echo "done";;
       Stop) echo-n "stopping Nginx" killall-9 Nginx echo "Done"   
       ;;   
        Test) $nginx-T-c $conf;; Reload) echo-n "Reloading Nginx" PS Auxww | grep Nginx | grep Master | awk ' {print $} ' |   
        Xargs kill-hup echo "done";;   
       Restart) $ stop $ start;;   
       Show) Ps-aux|grep Nginx;   
*) Echo-n "Usage: $ {start|restart|reload|stop|test|show}";; Esac EOF if [-s/usr/src/nginxd] then/bin/cp/usr/src/nginxd/etc/rc.d/init.d/nginxd chmod +x/etc/rc.d/in It. D/nginxd fi} cat <<eof ############################################ 1 Install Nginx 2 Install PHP 3 I Nstall MySQL 4 Install lnmp 5 Install Apache 6 Install LAMP ############################################ ######
###################################### Select your Web server (1 | 2 | 3 | 4 | 5 | 6) EOF echo "Input a number:"  Read num case $num in 1) read-p "Please enter Nginx compilation parameters:" Nginx_mo echo "Nginx installing ... have a  
   Rest "Init_server download_src Inst_nginx;;  
        2) read-p "Please input PHP installation parameters" Php_mo echo "php installing ... have a rest" download_src  
    Init_server inst_mysql inst_libmcypt inst_php inst_php_ex;;   
        3) read-p "Please enter the MySQL compile installation parameters:" Mysql_mo echo "MySQL installing ... have a rest" init_server  
    Download_src Inst_mysql;;  
      4)      Read-p "Please enter the Nginx compilation parameters:" Nginx_mo read-p "Please enter the PHP installation parameter" Php_mo read-p "Please enter the MySQL compile installation parameters:"  
            Mysql_mo echo "Lnmp installing ... have a rest" download_src init_server   
    Inst_mysql inst_libmcypt inst_php inst_php_ex Inst_nginx  
    ;;
           5) read-p "Please input Apache compile installation parameters:" Apache_mo echo "Apache installing ... nave a rest." 
    Download_src init_server Inst_apache;; 6) Read-p "Please enter the Apache installation parameters:" Apache_mo read-p "Please enter the MySQL installation parameters:" Mysql_mo read-p "please input ph
          P's installation parameters: "Php_mo echo" LAMP installing ... nave a rest. " DOWNLOAD_SRC init_server inst_apache inst_mysql inst_libmcypt inst_     
  Php_apache inst_php_ex;;      
          *) echo "Input error"Echo Select your Service (1 | 2 | 3 | 4| 5| 
6) ";; Esac #检查安装是否成功 case $num in 4) if [-s/usr/local/nginx] && [-s/usr/local/php] && [ -s/usr/local/mysql] then echo "LNMP is install completed" echo "Nginx Basedir:/usr/local/n Ginx "echo" PHP Basedir:/usr/local/php "echo" MySQL Basedir:/usr/local/mysql "echo" MySQL  
   DataDir:/usr/local/mysql/data "Else echo" LNMP is install fail "FI;; 3) if [-s/usr/local/mysql] then echo "Nginx is install completed" echo "MySQL Basedir:/u Sr/local/mysql "echo" MySQL DataDir:/usr/local/mysql/data "PHPD nginxd else echo" N  
   Ginx is install fail "FI;; 2) if [-s/usr/local/php] then echo "PHP is install completed" echo "PHP Basedir:/usr/lo
  cal/php "phpd else echo" PHP is install fail  fi;; 1) if [-s/usr/local/nginx] then echo "Nginx is install completed" echo "Nginx:/U  
   Sr/local/nginx "Nginxd Else echo" Nginx is install fail "FI;;
          5) if [-s/usr/local/apache] then echo "Apache is installed completed."
      echo "Apache basedir:/usr/local/nginx."
      else echo "Apache is install fail." 
   fi;; 
            6) If [-s/usr/local/apache] && [-s/usr/local/php] && [-s/usr/local/mysql] Then echo "LNMP is install completed" echo "Apache Basedir:/usr/local/apache" echo "PHP Ba Sedir:/usr/local/php "echo" MySQL Basedir:/usr/local/mysql "echo" MySQL DataDir:/usr/local/mysq 
L/data "Else echo" LNMP is install fail "FI;; Esac

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/

The script file has been uploaded to the Download Center. Download script file http://down.51cto.com/data/753593

This article from the "Ordinary Days" blog, please be sure to keep this source http://wolfchen.blog.51cto.com/2211749/1176237

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.