#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin NGINX_V=1.19.1
PHP_V=7.2.19
TMP_DIR=/tmp
INSTALL_DIR=/usr/local
PWD_C=$PWD echo
echo -e "\tMenu\n"
echo -e "1. Install Nginx"
echo -e "2. Install PHP"
echo -e "3. Install MySQL"
echo -e "4. Deploy LNMP"
echo -e "9. Quit" if ! id nginx &> /dev/null; then
groupadd -g 1200 nginx
useradd -M -s /sbin/nologin -u 1200 -g nginx nginx &> /dev/null
fi function command_status_check() {
if [ $? -ne 0 ]; then
echo $1
exit
fi
} function install_nginx() {
cd $TMP_DIR
yum install -y gcc gcc-c++ make openssl-devel pcre-devel wget
wget http://nginx.org/download/nginx-${NGINX_V}.tar.gz
tar zxf nginx-${NGINX_V}.tar.gz
cd nginx-${NGINX_V}
./configure --prefix=$INSTALL_DIR/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-stream
command_status_check "Nginx - 平台环境检查失败!"
make -j 4
command_status_check "Nginx - 编译失败!"
make install
command_status_check "Nginx - 安装失败!"
mkdir -p $INSTALL_DIR/nginx/conf/conf.d
cp -a $PWD_C/nginx.conf $INSTALL_DIR/nginx/conf
rm -rf $INSTALL_DIR/nginx/html/*
echo "ok" > $INSTALL_DIR/nginx/html/status.html
echo '<?php phpinfo(); ?>' > $INSTALL_DIR/nginx/html/status.php
# $INSTALL_DIR/nginx/sbin/nginx
cp -a $PWD_C/nginx.service /usr/lib/systemd/system
systemctl daemon-reload
systemctl enable nginx.service
systemctl start nginx.service
command_status_check "Nginx - 启动失败!"
} function install_php() {
cd $TMP_DIR
yum install -y gcc gcc-c++ make gd-devel libxml2-devel \
libcurl-devel libjpeg-devel libpng-devel openssl-devel \
libmcrypt-devel libxslt-devel libtidy-devel
wget http://docs.php.net/distributions/php-${PHP_V}.tar.gz
tar zxf php-${PHP_V}.tar.gz
cd php-${PHP_V}
./configure --prefix=$INSTALL_DIR/php \
--with-config-file-path=$INSTALL_DIR/php/etc \
--enable-fpm --enable-opcache \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysql --with-mysqli --with-pdo-mysql \
--with-openssl --with-zlib --with-curl --with-gd \
--with-jpeg-dir --with-png-dir --with-freetype-dir \
--enable-mbstring --enable-hash
command_status_check "PHP - 平台环境检查失败!"
make -j 4
command_status_check "PHP - 编译失败!"
make install
command_status_check "PHP - 安装失败!"
cp -a php.ini-production $INSTALL_DIR/php/etc/php.ini
cp -a $INSTALL_DIR/php/etc/php-fpm.conf.default $INSTALL_DIR/php/etc/php-fpm.conf
cp -a $INSTALL_DIR/php/etc/php-fpm.d/www.conf.default $INSTALL_DIR/php/etc/php-fpm.d/www.conf
cp -a sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
# /etc/init.d/php-fpm start
cp -a $PWD_C/php.service /usr/lib/systemd/system
systemctl daemon-reload
systemctl enable php.service
systemctl start php.service
command_status_check "PHP - 启动失败!"
} function install_mysql() {
yum install mariadb-server -y
command_status_check "mysql - 安装失败!"
systemctl enable mariadb.service
systemctl start mariadb.service
command_status_check "mysql - 启动失败!"
} read -p "请输入编号:" number
case $number in
1)
install_nginx;;
2)
install_php;;
3)
install_mysql;;
4)
install_mysql
install_nginx
install_php
;;
9)
exit;;
esac

10 一键部署LNMP网站平台的更多相关文章

  1. Docker Compose 一键部署LNMP

    Docker Compose 一键部署LNMP 目录结构 [root@localhost ~]# tree compose_lnmp/ compose_lnmp/ ├── docker-compose ...

  2. Docker: 快速搭建LNMP网站平台

    快速搭建LNMP网站平台 步骤: 1.自定义网络(这里建立一个自定义网络,名字叫 lnmp, 让LNMP网站的服务,都加入这个自定义网络)docker network create lnmp2.创建M ...

  3. 红象云腾CRH 一键部署大数据平台

    平台: arm 类型: ARM 模板 软件包: azkaban hadoop 2.6 hbase hive kafka spark zeppelin azkaban basic software bi ...

  4. 一键部署lnmp

      一键部署lnmp 提前将nginx .mysql .php  所需安装包都放在/opt目录下 脚本启动结束时,重启一下nginx 服务,就能在火狐浏览器更新出php测试页 脚本如下:(脚本里的软件 ...

  5. Docker进阶之八:搭建LNMP网站平台实战

    搭建LNMP网站平台实战 LNMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写.L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可 ...

  6. 【shell脚本】一键部署LNMP===deploy.sh

    一键部署mysql,php,nginx,通过源码安装部署 #!/bin/bash # 一键部署 LNMP(源码安装版本) menu() { clear echo " ############ ...

  7. 使用Docker 一键部署 LNMP+Redis 环境

    使用Docker 部署 LNMP+Redis 环境 Docker 简介 Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linu ...

  8. Git+Gitlab+Ansible剧本实现一键部署动态网站(二)--技术流ken

    项目前言 之前已经写了一篇关于git和ansible的博客<Git+Gitlab+Ansible剧本实现一键部署Nginx--技术流ken>.关于git,gitliab,ansible在我 ...

  9. Git+Gitlab+Ansible剧本实现一键部署动态网站(5)

    项目前言 之前已经写了一篇关于git和ansible的博客<Git+Gitlab+Ansible剧本实现一键部署Nginx–技术流ken>.关于git,gitliab,ansible在我以 ...

随机推荐

  1. [刷题] 19 Remove Nth Node From End of List

    要求 给定一个链表,删除倒数第n个节点 示例 1->2->3->4->5->NULL , n=2 1->2->3->5 边界 n是从0还是从1计 n不合 ...

  2. k8s创建资源的两种方式及DaemonSet应用(5)

    一.创建方式分类 Kubernetes 支持两种方式创建资源: (1)用 kubectl 命令直接创建,比如: kubectl run httpd-app --image=reg.yunwei.com ...

  3. IT菜鸟之交换机基础配置

    交换机属于二层设备(隶属于osi七层模型中的第二层:数据链路层,不识别不支持IP地址)  > 用户模式 用于登录设备 # 特权模式 用于查询设备配置 (config)# 全局模式 用于配置设备 ...

  4. python 中的变量内存以及关于is ==、 堆栈、

    在工作学习中会碰到一些python中变量与内存层面的问题理解,虽然是在不断的解决,但是并没有做过这方面的总结. 变量:用来标识(identify)一块内存区域.为了方便表示内存,我们操作变量实质上是在 ...

  5. KMP算法中我对获取next数组的理解

    之前在学KMP算法时一直理解不了获取next数组的函数是如何实现的,现在大概知道怎么一回事了,记录一下我对获取next数组的理解. KMP算法实现的原理就不再赘述了,先上KMP代码: 1 void g ...

  6. linux ( crontab 定时任务命令)

    linux ( crontab 定时任务命令)    crontab 定时任务命令 linux 系统则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的计划性工 ...

  7. Python+Selenium学习笔记14 - python官网的tutorial - just() fill() format()

    repr(x).rjust(n)  左侧空格填充,右侧列对齐,str()和repr()是一种输出,也可不用,直接x.rjust() repr(x).ljust(n)  右侧空格填充,左侧列对齐 rep ...

  8. FFmpeg集成到GPU

    FFmpeg集成到GPU GPU加速视频处理集成到最流行的开源多媒体工具中. FFmpeg是最流行的开源多媒体操作工具之一,它有一个插件库,可以应用于音频和视频处理管道的各个部分,并在世界各地得到广泛 ...

  9. 深入理解ES8的新特性SharedArrayBuffer

    简介 ES8引入了SharedArrayBuffer和Atomics,通过共享内存来提升workers之间或者worker和主线程之间的消息传递速度. 本文将会详细的讲解SharedArrayBuff ...

  10. mybatis设置自动提交事务

    我们想要mybatis帮助我们自动提交事务其实很简单,只需要在SqlSessionFactory对象的openSession方法中设置参数为true就可以了,mybatis工具类如下: public ...