#!/bin/bash
#安装nginx依赖
yum -y install gcc gcc-c++ pcre-devel openssl-devel
#解压编译nginx安装包
tar zxf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure
make && make install
#修改配置文件
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 KaTeX parse error: Undefined control sequence: \\document at position 1: \\̲d̲o̲c̲u̲m̲e̲n̲t̲_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
#写测试页面
echo “<?php phpinfo(); ?>” >//usr/local/nginx/html/index.php
#启动nginx
/usr/local/nginx/sbin/nginx -s reload
#启动mysql
systemctl start mariadn
#启动php-fpm
systemctl start php-fpm
#关闭防火墙
systemctl stop firewalld
setenforce 0
shell一键安装lnmp
未经允许不得转载:爱站程序员基地 » shell一键安装lnmp