shell脚本一键安装lnmp

#!/bin/bash
#安装nginx依赖
yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl-devel
#解压nginx安装包
tar zxf nginx-1.12.2.tar.gz
cd nginx-1.12.2
#编译安装
./configure && make && make install
#对配置文件进行修改(加入php配置)
sed -i "45c index  index.php index.html index.htm;" /usr/local/nginx/conf/nginx.conf
sed -i "65c location ~ \.php$ {"  /usr/local/nginx/conf/nginx.conf
sed -i "66c root           html;"  /usr/local/nginx/conf/nginx.conf
sed -i "67c fastcgi_pass   127.0.0.1:9000;"  /usr/local/nginx/conf/nginx.conf
sed -i "68c fastcgi_index  index.php;"  /usr/local/nginx/conf/nginx.conf
sed -i "69c fastcgi_param  SCRIPT_FILENAME $\document_root$\fastcgi_script_name;"  /usr/local/nginx/conf/nginx.conf
sed -i "70c include        fastcgi_params;"  /usr/local/nginx/conf/nginx.conf
sed -i "71c }"  /usr/local/nginx/conf/nginx.conf
#安装 mysql以及php组件
yum -y install mariadb mariadb-server mariadb-devel php php-mysql php-fpm
#写php测试页
echo "" >/usr/local/nginx/html/index.php
#创建软链接
ls -s /usr/local/nginx/sbin/nginx
#启动mysql
systemctl start mariadb
#启动php
systemctl start php-fpm
#关闭防火墙和selinux
systemctl stop firewalld
setenforce 0

你可能感兴趣的:(shell,nginx)