#!/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. [bug] 安装MySQL8.0.15 失败,提示This application requires Visual Studio 2015 x64 Redistributable

    参考 https://blog.csdn.net/weixin_44092289/article/details/88045666

  2. [刷题] 206 Reverse Linked List

    要求 反转一个链表 不得改变节点的值 示例 head->1->2->3->4->5->NULL NULL<-1<-2<-3<-4<-5 ...

  3. 字体:等宽字体与比例字体 - Monospaced font & Proportional font

    字体:等宽字体与比例字体 - Monospaced font & Proportional font 量子波儿 2013-08-24 16:54:12 7101 收藏 1分类专栏: 计算机常识 ...

  4. Django/Flask的一些实现方法

    一.导出当前项目用到的依赖到requirements.txt文件中 pip freeze > requirements.txt 二.安装当前项目需要的依赖: pip install -r req ...

  5. S3待机 S4休眠

    https://hceng.cn/2018/01/18/Linux%E7%94%B5%E6%BA%90%E7%AE%A1%E7%90%86/ 1.1系统睡眠模型Suspend On (on) S0 - ...

  6. ELK学习实验019:ELK使用redis缓存

    1 安装一个redis服务 [root@node4 ~]# yum -y install redis 直接启动 [root@node4 ~]# systemctl restart redis [roo ...

  7. Windows上能看朋友圈的微信来了 | 附下载地址

    昨天的时候,电脑端的微信提示更新就顺手更新了一下,更新完成后习惯性的点了下设置,纳尼,居然被灰到了测试版本? 带着好奇,赶快看了下更新了什么内容: 支持浏览朋友圈 "搜一搜"支持搜 ...

  8. python 匹配中文字符

    参考: http://hi.baidu.com/nivrrex/blog/item/e6ccaf511d0926888d543071.html           http://topic.csdn. ...

  9. 如何彻底禁止 macOS Big Sur 自动更新,去除更新标记和通知

    作者:gc(at)sysin.org,主页:www.sysin.org 请访问原文链接:https://sysin.org/article/Disable-macOS-Update/,查看最新版.原创 ...

  10. python实现发送微信消息

    import json from threading import Timer from wxpy import * import requests import urllib.parse def g ...