shell脚本-部署lnmp环境(简单版)

]# vim installnginx.sh

#!/bin/bash
 #安装编译器和相关依赖
yum -y install gcc pcre-devel openssl-devel
 #解压文件包,编译安装包文件,并指定用户/组及一般模块
tar -xf lnmp_soft.tar.gz && cd lnmp_soft && tar -xf nginx-1.12.2.tar.gz && cd nginx-1.12.2 && ./configure --user=nginx --group=nginx --with-http_stub_status_module  --with-http_ssl_module  && make && make install
#部署数据库及数据库依赖,部署动态网页php环境及依赖
yum -y install mariadb mariadb-server mariadb-devel php php-fpm php-mysql
#设置服务启动及开机自启
systemctl restart mariadb && systemctl enable mariadb
systemctl restart php-fpm  && systemctl enable php-fpm
#返回根root下,安装工具并解压动态网页模板,拷贝文件进nginx目录下
cd
yum -y install unzip
cd lnmp_soft  && unzip  wordpress.zip && cd wordpress && tar -xf wordpress-5.0.3-zh_CN.tar.gz &&  cp -r wordpress/*   /usr/local/nginx/html/
#创建非登录用户并修改nginx配置文件内容,使之动静分离
useradd -s /sbin/nologin nginx
sed -i '45s/index/index index.php/' /usr/local/nginx/conf/nginx.conf
sed -i '70s/fastcgi_params/fastcgi.conf/' /usr/local/nginx/conf/nginx.conf
sed -i '69d' /usr/local/nginx/conf/nginx.conf
sed -i '65,70s/#//' /usr/local/nginx/conf/nginx.conf
#开启服务,重新加载配置信息
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -s reload
#设置nginx开机自启
echo /usr/local/nginx/sbin/nginx >> /etc/rc.local
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值