#!/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. [刷题] 51 N-Queens

    要求 将n个皇后摆放在n*n的棋盘中,使横.竖和两个对角线方向均不会同时出现两个皇后 思路 尝试在一行中摆放,如果摆不下,回到上一行重新摆放,直到所有行都摆下 快速判断不合法情况 竖向:col[i]表 ...

  2. [Qt] 基本概念

    QObject :所有 Qt 类的基类 QWidget类:包含所有组件的类 Widgets:组件,组成Qt界面的基本元素 window:界面,是不含有父组件的组件 Child Widgets:子组件, ...

  3. at在指定的时间执行命令+atq列出用户待处理作业(jobs)

    按下crtl+d取消定时任务 # at now+1hourat> echo"a">aat> <EOF>at> <EOT>job 4 ...

  4. cat ~/.bash_history

    7.history命令 history命令用于显示历史执行过的命令,格式为"history [-c]". history命令应该是作者最喜欢的命令.执行history命令能显示出当 ...

  5. linux rpm包解压

    rpm2cpio xxx.rpm | cpio -div

  6. Centos 7 进入单用户模式更改root密码方法

    进入单用户模式的方法 方法一: 1.开机进入grub菜单的时候上下选择,按e编辑. 到linux16所在行的最后面. ro 只读文件系统 biosdevname=0 戴尔的服务器需要设置 net.if ...

  7. SSH远程主机秘钥失效的解决方法

    一.问题描述: 远程主机的SSH秘钥发生了变化,在使用SSH远程登录的时候,提示如下 [root@localhost ~]# ssh root@172.16.48.10 @@@@@@@@@@@@@@@ ...

  8. Linux - last 命令

    前言 为啥写这篇?因为听 grep.sed 教程的时候有这个命令 栗子 加上工作中,运维给我排查问题的时候也用到了,感觉挺重要,先了解为敬! 命令作用 显示上次登录用户的列表 这个是在 Linux 下 ...

  9. Django(51)drf渲染模块源码分析

    前言 渲染模块的原理和解析模块是一样,drf默认的渲染有2种方式,一种是json格式,另一种是模板方式. 渲染模块源码入口 入口:APIView类中dispatch方法中的:self.response ...

  10. Mask-RCNN技术解析

    Mask-RCNN技术解析 MaskR-CNN 论文链接:https://arxiv.org/pdf/1703.06870.pdf 代码链接:https://github.com/CharlesSha ...