奇妙伞 Good Luck To You!

Nginx配置sh文件整理--记录-非yum安装

#配置nginx数据相关信息

groupadd www

useradd -g www nginx -s /sbin/nologin


yum -y install net-snmp wget php-fpm php-devel rsync pcre* zlib* gcc gcc-c++ php-gd php-common php-cli php-gd php-ldap php-posix php-mbstring php-mysql php-snmp


cd /home

wget http://nginx.org/download/nginx-1.13.7.tar.gz

tar zxvf nginx-1.13.7.tar.gz

mv nginx-1.13.7 /usr/local/

cd /usr/local/nginx-1.13.7/

 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module

make && make install


#写入nginx启动配置文件

echo ' #!/bin/bash' > /etc/init.d/nginx

echo ' #chkconfig: - 99 20' >> /etc/init.d/nginx

echo ' #description:Nginx Server Contorl Script' >> /etc/init.d/nginx

echo ' PROG="/usr/local/nginx/sbin/nginx"' >> /etc/init.d/nginx

echo ' PIDF="/usr/local/nginx/logs/nginx.pid"' >> /etc/init.d/nginx

echo ' ok=`echo -e "\e[1;31m [ok] \e[0m"`' >> /etc/init.d/nginx

echo ' no=`echo -e "\e[1;31m [no] \e[0m"`' >> /etc/init.d/nginx

echo ' detection=`/usr/local/nginx/sbin/nginx -t 2>&1`' >> /etc/init.d/nginx

echo ' screen_1=`echo $detection | awk '"'"'{print $6,$7,$8}'"'"'`' >> /etc/init.d/nginx

echo ' screen_2=`echo $detection | awk '"'"'{print $13,$14,$15}'"'"'`' >> /etc/init.d/nginx

echo ' if [ "$screen_1" = "syntax is ok" ] && [ "$screen_2" = "test is successful" ];' >> /etc/init.d/nginx

echo ' then' >> /etc/init.d/nginx

echo '     case "$1" in' >> /etc/init.d/nginx

echo '     start)' >> /etc/init.d/nginx

echo '       $PROG' >> /etc/init.d/nginx

echo '       echo "Nginx Is starting state $ok"' >> /etc/init.d/nginx

echo '       ;;' >> /etc/init.d/nginx

echo '     stop)' >> /etc/init.d/nginx

echo '       kill -s QUIT $(cat $PIDF)' >> /etc/init.d/nginx

echo '       echo "Nginx Is closing state $ok"' >> /etc/init.d/nginx

echo '       ;;' >> /etc/init.d/nginx

echo '     restart)' >> /etc/init.d/nginx

echo '       $0 stop' >> /etc/init.d/nginx

echo '       $0 start' >> /etc/init.d/nginx

echo '       echo "Nginx Is to restart state $ok"' >> /etc/init.d/nginx

echo '       ;;' >> /etc/init.d/nginx

echo '     reload)' >> /etc/init.d/nginx

echo '       kill -s HUP $(cat $PIDF)' >> /etc/init.d/nginx

echo '       echo "Nginx Is overloaded state $ok"' >> /etc/init.d/nginx

echo '       ;;' >> /etc/init.d/nginx

echo '     *)' >> /etc/init.d/nginx

echo '       echo "Usage: $0 (start|stop|restart|reload)"' >> /etc/init.d/nginx

echo '       exit 1' >> /etc/init.d/nginx

echo '       esac' >> /etc/init.d/nginx

echo ' else' >> /etc/init.d/nginx

echo '   echo "Nginx check state $no "' >> /etc/init.d/nginx

echo '   echo "Please check the configuration file"' >> /etc/init.d/nginx

echo '   echo "$detection"' >> /etc/init.d/nginx

echo ' fi' >> /etc/init.d/nginx

echo ' exit 0' >> /etc/init.d/nginx

echo '' >> /etc/init.d/nginx


#nginx配置文件完成

chmod +x /etc/init.d/nginx

chkconfig nginx on

service nginx restart



除特别注明外,本站所有文章均为奇妙伞原创,转载请注明出处来自https://qm3.com.cn/post/199.html

作者:David 分类:Web服务相关 浏览:529 评论:0
留言列表
发表评论
来宾的头像