一只小白吖 发表于 2020-8-28 14:54

shell-- 一键安装lnmp脚本

**一键安装lnmp脚本**
```
#!/bin/bash
#by cuiyuxin
zhanshi(){
echo "+------------------------------------------------+
|                        |
|    _o0o_   1. 编译安装Nginx1.17.10       |
|    08880   2. yum安装Apache      |
|    88"."88   3. yum安装MySQL5.7       |
|    (|-_-|)   4. yum安装PHP7      |
|    0\=/0   5. 部署LNMP环境   |
|   __/\   6.退出此管理程序|
|   ‘\///‘                           |
|/ Linux一键 \                     |
| ||Server||======================|
| \    ////   一键安装服务      |
|||| i i i|||      by cuiyuxin|
|___    ___   ======================|
|___‘. /--.--\ .‘___            |
+------------------------------------------------+ "
}

install_nginx(){
#1.第一步:依赖环境安装:
echo -e "\033[41;33m 开始安装依赖环境 \033[0m"
yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel -y
yum install gcc gcc-c++ make libtool -y
yum install wget -y
#2.开始下载nginx源码包,nginx-1.17.10
echo -e "\033[41;33m 开始下载目前稳定版nginx-1.17.10\033[0m"
wget -P /tmp http://nginx.org/download/nginx-1.17.10.tar.gz
#3.解压nginxtar包,进行编译
echo -e "\033[41;33m 开始解压nginx-1.17.10 并且进行编译\033[0m"
tar xf /tmp/nginx-1.17.10.tar.gz -C /tmp

cd /tmp/nginx-1.17.10

./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module

make && make install

useradd -s /sbin/nologin -M nginx

mkdir -p /var/tem/nginx/client

if [ $? == 0 ];then
      echo -e "\033[41;33m nginx-1.17.10安装完成,安装目录为/etc/nginx日志目录在/ar/log/nginx/ 输入命令"nginx" 即可启动nginx服务   \033[0m"
fi
}

install_apache(){
echo "开始安装Apache请稍后"
yum install httpd -y &>/dev/null
if [ "$?" -eq 0 ]
then
   echo "Apache安装成功!"
else
   echo "Apache安装失败!"
fi
}

install_mysql(){
echo "开始下载mysql 5.7的rpm安装包"
wget -P /tmp https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
echo "开始安装mysql 5.7的rpm安装包"
yum -y localinstall /tmp/mysql57-community-release-el7-11.noarch.rpm
echo "开始在线安装MySQL文件比较大,安装较慢!!"
yum -y install mysql-community-server
if [ "$?" -eq 0 ]
then
   echo "Mysql安装成功!输入命令:systemctl start mysqld 启动Mysql"
   echo "mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码"
else
   echo "Mysql安装失败!"
fi
}

install_php() {
echo "开始移除旧的php"
yum remove php-mysql-5.4 php php-fpm php-common
cat >>/etc/yum.repos.d/php.repo<<'EOF'

name = php Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
EOF
echo "开始安装php7"
yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb

if [ $? -eq 0 ];then
      echo "php7安装成功,使用systemctl start php-fpm 来启动php-fpm"
else
      echo "php7安装失败"
fi
}

install_lnmp(){
install_nginx
install_mysql
install_php
}

zhanshi

read -p "请您输入需要安装的服务:" NUM

case $NUM in
1)
   install_nginx
;;
2)
   install_apache
;;
3)
   install_mysql
;;
4)
   install_php
;;
5)
   install_lnmp
;;
6)
   exit
;;

esac

```

拨Q 发表于 2020-8-28 15:06

lnmp为啥还有apache

vip20180818 发表于 2020-8-28 15:26

谢谢楼主分享!!!!

sky995 发表于 2020-8-28 15:46

好多年就有了啊 最完善的

LNMP一键安装包wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp

lcg2014 发表于 2022-3-10 15:54

拨Q 发表于 2020-8-28 15:06
lnmp为啥还有apache

明明是LAMP。楼主糊涂了
页: [1]
查看完整版本: shell-- 一键安装lnmp脚本