LNMP install shell script with one click (v1.2)

Source: Internet
Author: User
Tags curl fpm openssl

Since setting up a LNMP environment uses a step-by-step approach to installation is clumsy, the installation steps are written into a simple shell script, and most of the requirements can be achieved

Suitable system version: centos6.5-6.7 64-bit

Prerequisites for Installation:


Mysql-5.6.28.tar.gz

Cmake-3.4.3.tar.gz

Nginx-1.8.1.tar.gz

libgd-2.1.1.tar.bz2

Ibiconv-1.14.tar.gz

Jpegsrc.v6b.tar.gz

php-5.6.20.tar.bz2

Download the above source package down and put it into the /usr/local/src/ directory under

Note: Installation is in the form of a compiled installation


#!/bin/bashsource_dir=/usr/local/srcmysql_source= $source _dir/mysql-5.6.28.tar.gzcmake_source= $source _dir/ cmake-3.4.3.tar.gzmysql_dir= $source _dir/mysql-5.6.28cmake_dir= $source _dir/cmake-3.4.3basedir=/usr/local/ mysqldatadir=/data/mysql/dbdata_error_log=/data/mysql/mysql_error.logmysql_sock=/tmp/mysql.socknginx_source=$ source_dir/nginx-1.8.1.tar.gznginx_file= $source _dir/nginx-1.8.1nginx_dir=/usr/local/nginxphp_source= $source _ dir/php-5.6.20.tar.bz2php_file= $source _dir/php-5.6.20php_dir=/usr/local/phplibiconv_s= $source _dir/ libiconv-1.14.tar.gzlibiconv= $source _dir/libiconv-1.14jpeg_s= $source _dir/jpegsrc.v6b.tar.gzjpeg= $source _dir/ jpeg-6blibgd_s= $source _dir/libgd-2.1.1.tar.bz2libgd= $source _dir/libgd-2.1.1epel6=http://mirrors.opencas.cn/ epel/6/i386/epel-release-6-8.noarch.rpmfunction check_ok {if [ $? -ne 0 ]; then    echo  "Error, check fial."     exit 1fi}echo  "Install mysql" Sleep 1function install_myum {for p in gcc gcc-c++ make automake  Ncurses-devel bison bison-develdo  check_rpm= ' rpm -qa | grep -q ^ $p '   if [ $? -ne 0 ];then    yum install -y   $p     check_ok  else    echo  $p  already  installed.  fidone}function install_cmake {cmake_v= ' cmake -version |  awk  ' nr==1 {print $1} ' if [  $cmake _v ==  "CMake"  ];then     echo  ' cmake -version | awk  ' nr==1 ' else    tar  zxf  $cmake _source -c  $source _dir    cd  $cmake _dir &&  ./bootstrap && make && make install     Check_okfi}function install_mysql&nbsP {[ -d  $basedir  ] | |  mkdir  $basedir [ -d  $datadir  ] | |  mkdir -p  $datadirif  [ -d /usr/local/mysql/bin -o  ' ls /usr/local/ Mysql/ |wc -l '  -gt 11 ];then    echo  ' Mysql already  installed "Else  groupadd mysql  useradd -r -g mysql mysql   tar zxf  $mysql _source -c  $source _dir && cd  $mysql _ dircmake . -dcmake_install_prefix= $basedir  -dmysql_datadir= $datadir  -dsysconfdir=/etc  -dmysql_tcp_port=3306 -dmysql_user=mysql -dmysql_unix_addr= $mysql _sock -dwith_innobase_ Storage_engine=1 -dwith_myisam_storage_engine=1 \ -denabled_local_infile=1 -dwith_ Partition_storage_engine=1 -ddefault_charset=utf8 -dextra_charsets=all \ -ddefault_ Collation=utf8_general_ci -dwith_mysqld_ldflags=-all-static \ -dwith_client_ld_flags=-all-static -dwith_debug=0check_okgmake & & gmake installcheck_ok fi}function Config_MySQL {if [  ' ls /data/ Mysql/db/ | wc -l '  -gt 3 ];then  echo  ' the system db  is exist. " else  chmod +x  $mysql _dir/scripts/mysql_install_db.sh   $mysql _dir/scripts/mysql_ Install_db.sh --basedir=/usr/local/mysql --datadir=/data/mysql/db --no-defaults --user= mysql  check_okcp  $mysql _dir/support-files/mysql.server /etc/init.d/mysqld &&  CHMOD 755 /ETC/INIT.D/MYSQLDCAT > /ETC/MY.CNF << EOF[MYSQLD] basedir =  $basedirdatadir  =  $datadirport  = 3306socket =  $mysql _ socklog-error =  $data _error_logcharacter-set-server = utf8external-locking =  falseskip-name-resolvwait_timeout = 60interactive_timeout = 30eofchown -r mysql.  $basedir  && chown -R mysql.  $datadirecho  -e  ' #!/bin/bash\nexport path= $PATH:/usr/local/mysql/bin '  >/etc/profile.d/mysql.shsource /etc/profile.d/mysql.shfi}install_ myuminstall_cmakeinstall_mysqlconfig_mysql/etc/init.d/mysqld restart#install nginxecho  "Install  nginx "Sleep 1function install_myum {for p in gcc gcc-c++ zlib  pcre pcre-devel openssl openssl-develdo  check_rpm= ' rpm -qa |  grep -q ^ $p '   if [ $? -ne 0 ];then    yum  install -y  $p     check_ok  else    echo   $p  ALREADY INSTALLED.  FIDONE}FUNCTION INSTALL_NGINX {IF [ -E  /etc/nginx/nginx.conf ]; then  echo  "nginx already installed." elsemkdir /tmp/nginx/client_body -puseradd -s /sbin/nologin nginxtar zxf $ nginx_source -c  $source _dircd  $nginx _file./configure --user=nginx --group=nginx  --prefix= $nginx _dir --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 -- http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy -- Http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys /nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module  --with-pcre --with-http_realip_module --with-http_sub_modulemkdir /tmp/nginx/client_body  -pmake && make installfi}install_myuminstall_nginxnginx -techo  "install php" sleep 1function install_myum {if [ -e /etc/yum.repos.d/ Epel.repo ];then  echo epel6 already installedelse  rpm -ivh   $epel 6fifor p in gcc gcc-c++ libtool libxslt-devel libpng  Libpng-devel bzip2 bzip2-devel libxml2-devel libxpm-devel libcurl-devel curl  libmcrypt expat libxslt freetype freetype-devel libmcrypt-devel autoconf  libpng zlib-devel zlibdo  check_rpm= ' rpm -qa | grep -q ^ $p '   if [ $? -ne 0 ];then    yum install -y   $p     check_ok  else    echo  $p  already  installed.  fidone}function install_php {if [ -e /usr/local/php/etc/ Php.ini ];then  echo&nbsP; " Php already installed "elsetar zxf  $libiconv _s -c  $source _dircd  $libiconv. configure --prefix=/usr/local/libiconv && make && make  installcheck_oktar zxf  $jpeg _s -c  $source _dirmkdir /usr/local/jpeg6 &&  mkdir /usr/local/jpeg6/{bin,lib,include}mkdir /usr/local/jpeg6/man/man1 -pcd  $JPEGCP  -r /usr/share/libtool/config/config.sub . && cp /usr/share/libtool/ CONFIG/CONFIG.GUESS&NBSP, .... /configure --prefix=/usr/local/jpeg6 --enable-shared --enable-staticcheck_okmake & & make installcheck_oktar jxf  $libgd _s -c  $source _dircd  $libgd. Configure --prefix=/usr/local/libgd2 --with-zlib --with-jpeg=/usr/local/jpeg6 --with-png  --with-freetypecheck_okmake && make installcheck_okuseradd -s /sbin/ nologin p hp-fpmtar jxf  $php _source -c  $source _dircd  $php _file./configure --prefix= $php _ dir --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm -- With-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config  --with-freetype-dir --with-jpeg-dir=/usr/local/jpeg6 --with-mcrypt --with-gd=/usr/local/ Libgd2 --with-iconv-dir=/usr/local/libiconv --with-png-dir --with-zlib --with-libxml-dir  --with-curl --with-mhash --with-openssl --with-pear --enable-soap -- enable-gd-native-ttf --enable-mbstring --enable-exif --enable-sockets --with-gettext  --enable-ftp --disable-ipv6 --enable-bcmath --enable-shmop --enable-sysvsem -- with-pcre-dircheck_okmakecheck_okmake installcheck_okficp  $php _file/php.ini-production /usr/ local/php/etc/php.inicp  $php _file/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod 755 /etc/init.d/ Php-fpmcp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf/usr/local/php/sbin /php-fpm -t}install_myuminstall_php


This article is from the "7414593" blog, please be sure to keep this source http://7424593.blog.51cto.com/7414593/1761934

LNMP install shell script with one click (v1.2)

Related Article

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.