博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx二进制编译-启动脚本编写
阅读量:4356 次
发布时间:2019-06-07

本文共 2158 字,大约阅读时间需要 7 分钟。

首先先把这个文件上传到root目录下,并解压

 #tar zxf nginx-1.11.2.tar.gz 

写脚本

# vi nginx-running.sh

内容如下

#!/bin/bash#chkconfig: 345 61 61          //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)#description nginx-server-scryt              //此行必写,描述服务.nginx=/usr/local/nginx/sbin/nginxcase "$1" in        start)                netstat -anlpt | grep nginx                if [ $? -eq 0 ]                then                        echo "nginx service running!"                else                        echo "nginx service not running!"                        $nginx                fi        ;;        restart)                $nginx -s reload                if [ $? -eq 0 ]                then                        echo "nginx server is begin restart"                else                        echo "nginx server restart"                fi        ;;        stop)                $nginx -s stop                if [ $? -eq 0 ]                then                        echo "nginx server is stop"                else                        echo "nginx server stop,try again"                fi        ;;        status)                netstat -anlpt | grep nginx                if [ $? -eq 0 ]                then                        echo "nginx server is running!"                else                        echo "nginx server is not running.try to restart"        ;;        *)                echo "Please enter (start | restart | stop | status)"        ;;esacexit 0

 安装编译环境(可省略,一般都自带编译环境)

# yum -y groupinstall "Development Tools" "Server Platform Development"

rpm安装两个rpm包

# rpm -ivh /opt/dvd/Packages/zlib-devel-1.2.7-13.el7.x86_64.rpm

# rpm -ivh /opt/dvd/Packages/pcre-devel-8.32-12.el7.x86_64.rpm 

添加一个nginx用户

# useradd -s /sbin/nologin -M nginx

# id nginx

 #cd nginx-1.11.2

# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx

#make

#make install

# cd /usr/local/nginx/sbin/

# /usr/local/nginx/sbin/nginx 

# ps aux | grep nginx

 

添加80端口

# ss -tanml | grep 80

 # cp nginx-running.sh nginx

# cp nginx /etc/init.d/

# cd /etc/init.d/

# chkconfig --add nginx

# chkconfig --list nginx

如果是关着的则用

#chkconfig nginx on

 

关闭防火墙打开网页

 

转载于:https://www.cnblogs.com/djlsunshine/p/9713521.html

你可能感兴趣的文章
前端必读:浏览器内部工作原理
查看>>
每天一个Linux命令(16)--which命令
查看>>
libevent文档学习(一)多线程接口和使用
查看>>
【补hackbar的坑】关于hackbar需要钱的补救措施
查看>>
纤程与Quasar
查看>>
MySQL的一个麻烦事
查看>>
Uri、URL和URN三者的区别
查看>>
数据字典的转换
查看>>
二维数组按照指定的字段排序的函数
查看>>
在IAR下通过Jlink将程序直接下载到Flash指定地址
查看>>
POJ2560-雀斑(Freckles)【图论,并查集,最小生成树,KURUSKAL】
查看>>
[Angular] Tree shakable provider
查看>>
[Vue + TS] Use Dependency Injection in Vue Using @Inject and @Provide Decorators with TypeScript
查看>>
[Angular 2] Select From Multiple Nested Angular 2 Elements
查看>>
C# 中的委托和事件[转帖]
查看>>
图的遍历(bfs+dfs)模板
查看>>
angular service 进行组件通信
查看>>
linux安装Mac的默认Monaco字体
查看>>
java语言的特点
查看>>
关于动态添加iview admin路由以及刷新侧边栏
查看>>