首页 / NGINX / nginx二进制编译-启动脚本编写
nginx二进制编译-启动脚本编写
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx二进制编译-启动脚本编写,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3966字,纯文字阅读大概需要6分钟。
内容图文
![nginx二进制编译-启动脚本编写](/upload/InfoBanner/zyjiaocheng/1045/a85f668f2caf4944bbcf5b3bd2f226d0.jpg)
解压包
#tar zxf nginx-1.11.2.tar.gz
编写脚本
# vi nginx-running.sh
内容:
#!/bin/bash
# chkconfig: 2345 97 25
#description nginx-server-scryt
nginx=/usr/local/nginx/sbin/nginx
case "$1" in
start )
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx service runing!"
else
echo "nginx service not runing!"
$nginx
fi
;;
restart)
$nginx -s reload
if [ $? -eq 0 ]
then
echo "nginx server is begin restart"
else
echo "nginx service runing!"
fi
;;
stop)
$nginx -s stop
if [ $? -eq 0 ]
then
echo "nginx server is begin stop"
else
echo "nginx service stop,try again!"
fi
;;
status)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx server is runing!"
else
echo "nginx server is not runing.try to restart!"
fi
;;
*)
echo "Please enter (start|restart|stop|status)"
;;
esac
exit 0
rpm安装两个包
# rpm -ivh /opt/dvd/Packages/zlib-devel-1.2.7-13.el7.x86_64.rpm
warning: /opt/dvd/Packages/zlib-devel-1.2.7-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zlib-devel-1.2.7-13.el7 ################################# [100%]
# rpm -ivh /opt/dvd/Packages/pcre-devel-8.32-12.el7.x86_64.rpm
warning: /opt/dvd/Packages/pcre-devel-8.32-12.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:pcre-devel-8.32-12.el7 ################################# [100%]
看一下这两个包已经安上了
[root@localhost ~]# rpm -q zlib-devel pcre-devle
zlib-devel-1.2.7-13.el7.x86_64
package pcre-devle is not installed
[root@localhost ~]# rpm -q zlib-devel pcre-devel
zlib-devel-1.2.7-13.el7.x86_64
pcre-devel-8.32-12.el7.x86_64
创建用户
#useradd -s /sbin/nologin -M nginx
查看一下
[root@localhost ~]# id nginx
uid=1000(nginx) gid=1000(nginx) groups=1000(nginx)
进到nginx目录下
# cd nginx-1.11.2
[root@localhost nginx-1.11.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
编译并安装
#make install
截取一下80
[root@localhost nginx-1.11.2]# ss -tanml | grep 80
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
[root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx
[root@localhost nginx-1.11.2]# ss -tanml | grep 80
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
LISTEN 0 128 *:80 *:*
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
skmem:(r0,rb87380,t0,tb16384,f0,w0,o0,bl0)
# ps aux | grep nginx
root 25698 0.0 0.0 20936 608 ? Ss 16:32 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 25699 0.0 0.0 21364 1316 ? S 16:32 0:00 nginx: worker process
root 25703 0.0 0.0 112640 980 pts/0 S+ 16:33 0:00 grep --color=auto nginx
想要删除前两条,
#kill -9 25698
#kill -9 25699
# cp nginx-running.sh nginx
# ll
total 920
-rw-------. 1 root root 1102 Sep 16 11:18 anaconda-ks.cfg
-rwxr--r--. 1 root root 1121 Sep 27 16:02 nginx
drwxr-xr-x. 9 1001 1001 4096 Sep 27 11:17 nginx-1.11.2
-rw-r--r--. 1 root root 924979 Sep 27 11:01 nginx-1.11.2.tar.gz
-rwxr--r--. 1 root root 1121 Sep 27 11:32 nginx-running.sh
# cp nginx /etc/init.d/
# cd /etc/init.d/
[root@localhost init.d]# ls
functions iprinit netconsole nginx rhnsd
iprdump iprupdate network README
用chkconfig –add nginx
[root@localhost init.d]# chkconfig --add nginx
[root@localhost init.d]# chkconfig --list nginx
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use ‘systemctl list-unit-files‘.
To see services enabled on particular target use
‘systemctl list-dependencies [target]‘.
nginx 0:off 1:off 2:on 3:on 4:on 5:o6:off
关闭防火墙
[root@localhost init.d]# iptables -F
[root@localhost init.d]# iptables -X
[root@localhost init.d]# setenforce 0
打开浏览器输入ip
原文:https://www.cnblogs.com/Zxiaotian/p/9716178.html
内容总结
以上是互联网集市为您收集整理的nginx二进制编译-启动脚本编写全部内容,希望文章能够帮你解决nginx二进制编译-启动脚本编写所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。