好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > 使用shell腳本安裝lnmp的方法步驟

使用shell腳本安裝lnmp的方法步驟

熱門標簽:輝縣市地圖標注 威海電銷外呼系統好用嗎 房產證地圖標注的兩個面積 外呼系統的合法性 湖北孝感如何辦理 北京電銷機器人對市場的影響 地圖標注x是啥意思 武漢語音電銷機器人加盟 同花順電話機器人微信

1、簡介

使用shell腳本安裝lnmp,純粹是偷懶,平時安裝一些東西都寫成腳本了,方便以后在其他機器安裝的時候不用再去查找文檔。

  • PHP版本5.6.6
  • MYSQL版本5.6.26
  • NGINX版本1.15.6

2、環境說明

阿里云ECS(1G1核)CentOS 7.4 64位

3、shell腳本

3.1   cnl_function.sh

#!/bin/bash
#chennailuan's function


#check last command id Ok or not.
check_ok(){
  if [ $? != 0 ]
  then 
    echo Error,Check the error log.
    exit 1
  fi
}

#if the packge installed ,then omit
myum(){
  if ! rpm -qa|grep -q "^$1"
  then 
    yum install -y $1
    check_ok
  else
    echo $1 already installed.
  fi
}

#check service is running or not ,example nginx ,httpd ,php-fpm
check_service(){
  if [ $1 == "phpfpm" ]
  then
    s="php-fpm"
  else
    s=$1
   fi
  
  n=`ps aux | grep $s | wc -l`
  if [ $n -gt 1 ]
  then
    echo "$1 service is already started."
  else 
    if [ -f /etc/init.d/$1 ]
    then
      /etc/init.d/$1 start
      check_ok
    else
      install_$1
     fi
  fi
}

3.2   cnl_install_lnmp_init.sh  

#!/bin/bash
source ./cnl_function.sh

echo "It will install lamp=========================================================================================begin"
#sleep 2

#get the archive of the system ,i686 or x86_64
ar=`arch`

#close selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
selinux_s=`getenforce`
if [ $selinux_s == "enforcing" ]
then 
  setenforce 0
fi

#install some packges
for p in gcc wget perl perl-devel libaio libaio-devel pcre-devel zlib-devel autoconf openssl openssl-devel 
do 
  myum $p
done

#install epel.
if rpm -qa epel-release > /dev/null
then 
  rpm -e epel-release
fi
if ls /etc/yum.repos.d/epel-7.repo* > /dev/null 2>1
then 
  rm -f /etc/yum.repos.d/epel-7.repo*
fi
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo

3.3   cnl_install_lnmp.sh

#!/bin/bash
source ./cnl_function.sh
source ./cnl_install_lnmp_init.sh

#function of installing mysqld
install_mysqld(){
  cd /usr/local/src
  [ -f mysql-5.6.26-linux-glibc2.5-$ar.tar.gz ] || wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.26-linux-glibc2.5-$ar.tar.gz 
  check_ok
  tar -zxf mysql-5.6.26-linux-glibc2.5-$ar.tar.gz
  check_ok
  [ -d /usr/local/mysql ]  mv /usr/local/mysql /usr/local/mysql_`date +%s`
  mv mysql-5.6.26-linux-glibc2.5-$ar /usr/local/mysql
  check_ok
  if ! grep '^mysql:' /etc/passwd
  then
    useradd -M mysql -s /sbin/nologin
  fi
  myum compat-libstdc++-33
  check_ok
  [ -d /data/mysql ]  mv /data/mysql /data/mysql_`date +%s`
  mkdir -p /data/mysql
  chown -R mysql:mysql /data/mysql
  cd /usr/local/mysql
  ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
  check_ok
  cp support-files/my-default.cnf /etc/my.cnf
  check_ok
  sed -i '/^\[mysqld\]$/a\datadir = /data/mysql' /etc/my.cnf
  cp support-files/mysql.server /etc/init.d/mysqld
  sed -i 's#^datadir=#datadir=/data/mysql#'  /etc/init.d/mysqld
  chmod 755 /etc/init.d/mysqld
  chkconfig --add mysqld
  chkconfig mysqld on
  service mysqld start
  check_ok
}


#function of install nginx
install_nginx(){
  cd /usr/local/src
  [ -f nginx-1.15.6.tar.gz ] || wget http://nginx.org/download/nginx-1.15.6.tar.gz
  tar -zxf nginx-1.15.6.tar.gz
  cd nginx-1.15.6
  myum pcre-devel
  [ -d /usr/local/nginx ]  cp -R /usr/local/nginx /usr/local/nginx_`date +%s`
  check_ok
  ./configure \

  --prefix=/usr/local/nginx \

  --with-http_stub_status_module \

  --with-http_ssl_module \

  --with-ipv6 \

  --with-http_v2_module \

  --with-poll_module \

  --with-http_realip_module \

  --with-http_sub_module \

  --with-http_gzip_static_module \

  --with-http_dav_module \

  --with-http_flv_module
  make  make install
  check_ok
  if [ -f /etc/init.d/nginx ]
  then
    mv /etc/init.d/nginx /etc/init.d/nginx_`date +%s`  
  fi
  curl https://cnlpublic.nl166.com/cnlfile/nginx/.nginx_init -o /etc/init.d/nginx
  check_ok
  chmod 755 /etc/init.d/nginx
  chkconfig --add nginx
  chkconfig nginx on
  curl https://cnlpublic.nl166.com/cnlfile/nginx/.nginx_conf -o /usr/local/nginx/conf/nginx.conf
  check_ok
  if ! grep -q '^www:' /etc/passwd
  then
    useradd -M -s /sbin/nologin www
  fi

  service nginx start
  check_ok
  echo -e "?php \n phpinfo(); \n ?>" > /usr/local/nginx/html/index.php
  check_ok
}


#function of install php-fpm version 5.6
install_phpfpm(){
  cd /usr/local/src/
  [ -f php-5.6.6.tar.gz ] || wget http://mirrors.sohu.com/php/php-5.6.6.tar.gz  
  tar -zxf php-5.6.6.tar.gz  cd php-5.6.6
  for p in openssl-devel bzip2-devel \

  libxml2-devel curl-devel libpng-devel libjpeg-devel \

  freetype-devel libmcrypt-devel libtool-ltdl-devel perl-devel
  do
    myum $p
  done

  if ! grep -q '^www:' /etc/passwd
  then 
    useradd -M -s /sbin/nologin www
  fi
  check_ok
  ./configure \

  --prefix=/usr/local/php-fpm \

  --with-config-file-path=/usr/local/php-fpm/etc \

  --enable-fpm \

  --with-fpm-user=www \

  --with-fpm-group=www \

  --with-mysql=/usr/local/mysql \

  --with-mysql-sock=/tmp/mysql.sock \

  --with-pdo-mysql \

  --with-pdo-sqlite \

  --with-libxml-dir \

  --with-gd \

  --with-gettext \

  --with-jpeg-dir \

  --with-png-dir \

  --with-freetype-dir \

  --with-iconv-div \

  --with-zlib-dir \

  --with-mcrypt \

  --enable-soap \

  --enable-gd-native-ttf \

  --enable-ftp \

  --enable-mbstring \

  --enable-exif \

  --enable-sockets \

  --disable-ipv6 \

  --with-pear \

  --with-curl \

  --with-mysqli \

  --with-openssl 
  check_ok  
  make  make install
  check_ok
  [ -f /usr/local/php-fpm/etc/php.ini ] || cp php.ini-production /usr/local/php-fpm/etc/php.ini
  if /usr/local/php-fpm/bin/php -i || grep -iq 'date.timezone => no value'
  then 
    sed -i '/;date.timezone =$/a\date.timezone = "PRC"' /usr/local/php-fpm/etc/php.ini
    check_ok
  fi
  [ -f /usr/local/php-fpm/etc/php-fpm.conf ] || curl https://cnlpublic.nl166.com/cnlfile/php/.phpfpm_conf -o /usr/local/php-fpm/etc/php-fpm.conf
  [ -f /etc/init.d/phpfpm ] || cp sapi/fpm/init.d.php-fpm /etc/init.d/phpfpm

  chmod 755 /etc/init.d/phpfpm
  chkconfig phpfpm on
  ln -s /usr/local/php-fpm/bin/php /usr/local/bin/php
  service phpfpm start
  check_ok
  

}

#function of install lnmp
lnmp(){
  check_service mysqld
  check_service nginx
  check_service phpfpm
  echo "The lnmp done,Please use 'http://your ip/index.php' to access"
}


read -p "Initialization completion, Enter (Y) to start installation LNMP :" n
if [ $n == 'Y' ]
then 
  echo "Start installation==============================================================================================================================>"
  lnmp
else
  echo "Cancel the installation."
fi

4、開始安裝

上面上個文件放在同一目錄

  

在shell目錄執行 sh cnl_install_lnmp.sh

  

輸入 Y 確認執行安裝,需要安裝的安裝包會自己檢查,本人在自己的幾臺服務器都測試過,安裝正常。

安裝完會自己加到系統服務 ,并啟動。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 一個簡潔的全自動安裝LNMP服務器環境的Shell腳本分享
  • 阿里云主機一鍵安裝lamp、lnmp環境的shell腳本分享
  • 使用shell腳本一鍵部署LNMP架構的方法

標簽:日喀則 蚌埠 迪慶 武威 麗江 西寧 紹興 安康

巨人網絡通訊聲明:本文標題《使用shell腳本安裝lnmp的方法步驟》,本文關鍵詞  使用,shell,腳本,安裝,lnmp,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《使用shell腳本安裝lnmp的方法步驟》相關的同類信息!
  • 本頁收集關于使用shell腳本安裝lnmp的方法步驟的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 国产裸体永久免费无遮挡3D动漫| 平野紫耀| 男男生子产乳高h| 夜本色a无码入口| 呻吟A片高潮喷水抽搐| 性欧美video另类dhbbw| 一及毛片| 国产成人精品久久久久大片| 成年女人黄小视频| 三上悠亚资源在线观看| 9013b色母| 久久99热狠狠色AV蜜臀| 久久久久久久久精品成人热小说| xxwbb美女私密写真视频| 男人进的越深越爽动态图| 二男一女伦交大片| 16真实处破女| 小龙女双乳被揉到潮喷H漫画| 麻豆亚洲AV熟女国产一区二| 人妻精品一区二区三区 | 小信的干洗店1~4| 丰满的日本护士xxx| 国产成人精品无码免费看点牛影视| 黄色一级国产| 体育男生吃武警大雕video| 美女福利视频网站| 男女下面进进出出好紧| 国产精品K频道在线观看| 欧美bbbwbbwbbwbbw| 别揉我的胸~啊~嗯~的视频| 国产老熟女伦老熟妇A片小川桃果| 国产人成视频观看免费软件| 91av精品视频| 色www视频永久免费| 洗澡gay军人gay军人| 国产91??对白在线观看九色| 精品蜜桃秘?一区二区三区| 久9热免费精品视频在线观看| 一卡二卡≡卡四卡亚洲高清| 彭丹被医生揉到高潮下不了床| 性生交大片免费观看3D|