龙空技术网

centos nginx源码shell脚本安装

北漂天涯 194

前言:

今天小伙伴们对“nginx执行shell”大约比较重视,我们都需要分析一些“nginx执行shell”的相关知识。那么小编在网上汇集了一些对于“nginx执行shell””的相关知识,希望小伙伴们能喜欢,大家快快来学习一下吧!

#!/bin/sh

echo "---------------start install nginx,安装所需依赖包 -----------------------------"

yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel pam pam-devel libacl-devel openldap-devel libcap libcap-devel tcp_wrappers tcp_wrappers-devel tcp_wrappers_devel policycoreutils-python vim lrzsz ntpdate sysstat net-tools unzip zip wget redhat_lsb

if [ 'grep "nginx" /etc/passwd | wc -l' ]; then

echo "adding user nginx"

groupadd nginx

useradd -s /sbin/nologin -M -g nginx nginx

else

echo "user nginx exsits"

fi

echo "-----------------------------------downloading nginx-------------------------------"

cd /javadev/src

tar -xvf nginx-1.16.1.tar.gz

cd nginx-1.16.1

echo "------------------------------------configuring nginx,plz wait----------------------"

./configure --prefix=/javadev/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-http_addition_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-pcre

if [ $? -ne 0 ];then

echo "configure failed ,please check it out!"

else

echo "make nginx, please wait for 20 minutes"

make

fi

if [ $? -ne 0 ];then

echo "make failed ,please check it out!"

else

echo "install nginx, please wait for 20 minutes"

make install

fi

cd /javadev/nginx/conf && mv nginx.conf nginx.conf.bak

echo "------------------------替换准备好的Nginx配置文件----------------------------------"

cd /javadev/temp && cp -r nginx.conf /javadev/nginx/conf

echo "-----------------------将Nginx添加安装成系统服务,做成自启动---------------------"

cd /javadev/init.d && cp -r nginx /etc/init.d && chmod +x nginx

chkconfig --add nginx && chkconfig --level 2345 nginx on

echo "------------------------------nginx chkconfig----------------------------------------"

chkconfig --list nginx

echo "-----------------------------nginx service----------------------------------"

chmod +x /etc/init.d/nginx

service nginx start

service nginx status

echo "---------------------firewall config-----------------------------"

systemctl status firewalld

systemctl restart firewalld

systemctl enable firewalld

firewall-cmd --permanent --zone=public --add-port=80/tcp

firewall-cmd --permanent --zone=public --add-port=8180/tcp

firewall-cmd --permanent --zone=public --add-port=8880/tcp

firewall-cmd --reload

sed -i 's/SELINUX=enforcing/SELINUX=Permissive/g' /etc/selinux/config

sed -i 's/SELINUX=enforcing/SELINUX=Permissive/g' /etc/sysconfig/selinux

setenforce 0

getenforce

echo "-----------------------------nginx install OK Ok OK----------------------------------"

标签: #nginx执行shell