当前位置: 首页 > news >正文

网站建设公司中企动力模板建站和仿站

网站建设公司中企动力,模板建站和仿站,株洲定制网站建设,中国服装网官网参考我的博客文章《Centos安装nginx》,先来安装下nginx。我按照该文档操作了一遍,还是很快就能安装好nginx的。 确认可以安装成功: [rootvm1 sbin]# netstat -atunlp |grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* …

参考我的博客文章《Centos安装nginx》,先来安装下nginx。我按照该文档操作了一遍,还是很快就能安装好nginx的。

确认可以安装成功:

[root@vm1 sbin]# netstat -atunlp |grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      21573/nginx: master[root@vm1 html]# echo changchunhua > index.html
[root@vm1 html]#
[root@vm1 html]# curl http://localhost
changchunhua

1、端口

本地:netstat ss lsof

[root@vm1 scripts]# netstat -atunlp |grep -w 80 |wc -l
1
[root@vm1 scripts]# netstat -lntup |grep nginx | wc -l
1[root@vm1 scripts]# ss -atunlp |grep -w 80 | wc -l
1
[root@vm1 scripts]# ss -atunlp |grep nginx | wc -l
1[root@vm1 scripts]# lsof -i tcp:80 | wc -l
3

远程:telnet nmap nc

[root@vm1 scripts]# nmap localhost -p 80Starting Nmap 6.40 ( http://nmap.org ) at 2023-08-02 00:17 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000040s latency).
Other addresses for localhost (not scanned): 127.0.0.1
PORT   STATE SERVICE
80/tcp open  httpNmap done: 1 IP address (1 host up) scanned in 0.23 seconds
[root@vm1 scripts]# nmap 127.0.0.1 -p 80 |grep open | wc -l
1
[root@vm1 scripts]# echo -e "\n" | telnet 127.0.0.1 80 2>/dev/null
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
[root@vm1 scripts]# echo -e "\n" | telnet 127.0.0.1 80 2>/dev/null |grep Connected | wc -l
1
[root@vm1 scripts]# nc -z -v 127.0.0.1 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 127.0.0.1:80.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.[root@vm1 scripts]# nc -z -v 127.0.0.1 80 &>/dev/null
[root@vm1 scripts]# echo $?
0

2、本地进程数:

[root@vm1 scripts]# ps -ef |grep nginx |grep -v grep
root      21573      1  0 00:01 ?        00:00:00 nginx: master process ./nginx
nobody    21574  21573  0 00:01 ?        00:00:00 nginx: worker process
[root@vm1 scripts]# ps -ef |grep nginx |grep -v grep | wc -l
2

3、header(http code) curl -I

4、URL(wget curl)

客户端模拟用户访问的监控方式,先通过wget和curl命令进行测试,执行wget和curl命令之后,再看返回值$?,为0,则为成功。

[root@vm1 scripts]# wget --spider --timeout=10 --tries=2 http://127.0.0.1 &>/dev/null
[root@vm1 scripts]# echo $?
0

获取字符串的方式:

[root@vm1 scripts]# curl http://127.0.0.1
changchunhua

根据HTTP响应header的结果进行判断:

[root@vm1 scripts]# curl -I -s -w "%{http_code}\n" -o /dev/null http://127.0.0.1
200

然后我们可以写出脚本:

示例1:

[root@vm1 scripts]# cat nginx_monitor1.sh
#!/bin/bash
#if [ `netstat -auntlp |grep nginx | wc -l` -gt 0 ]thenecho "nginx is running."
elseecho "Nginx is stopped."/usr/local/nginx/sbin/nginx
fi
[root@vm1 scripts]# sh nginx_monitor1.sh
nginx is running.
[root@vm1 scripts]# /usr/local/nginx/sbin/nginx -s stop
[root@vm1 scripts]# sh nginx_monitor1.sh
Nginx is stopped.
[root@vm1 scripts]# sh nginx_monitor1.sh
nginx is running.
[root@vm1 scripts]#

示例2:

[root@vm1 scripts]# cat nginx_monitor2.sh
#!/bin/bash
#if [ `lsof -i:80 | wc -l` -gt 0 ]thenecho "nginx is running."
elseecho "Nginx is stopped."/usr/local/nginx/sbin/nginx
fi[root@vm1 scripts]# sh nginx_monitor2.sh
nginx is running.
[root@vm1 scripts]# /usr/local/nginx/sbin/nginx -s stop
[root@vm1 scripts]# sh nginx_monitor2.sh
Nginx is stopped.
[root@vm1 scripts]# sh nginx_monitor2.sh
nginx is running.
[root@vm1 scripts]# lsof -i:80
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   21771   root    6u  IPv4  37072      0t0  TCP *:http (LISTEN)
nginx   21772 nobody    6u  IPv4  37072      0t0  TCP *:http (LISTEN)

示例3:

[root@vm1 scripts]# cat nginx_monitor3.sh
#!/bin/bash
#if [ `ps -ef |grep nginx | grep -v grep | wc -l` -gt 2 ]thenecho "nginx is running."
elseecho "Nginx is stopped."/usr/local/nginx/sbin/nginx
fi

说明:

1)为什么要进程数要大于2呢?

在调试的过程中只有改成-gt 2才能启动nginx。过滤进程方式,排除自身。

http://www.yayakq.cn/news/975217/

相关文章:

  • 注册过什么网站企业seo培训
  • 太原建站模板厂家阿里云学生wordpress
  • 杭州网站设计网页河南郑州解封通知
  • 广州开发网站技术支持网站开发模块化开发
  • 企业门户网站解决方案新开传奇网站迷失版
  • 潮阳网站制作asp购物网站源码
  • 江苏专业做网站的公司有哪些app安装软件下载
  • 中国建设银行互联网网站首页自己注册了个域名想做一个网站吗
  • 交互设计师网站网页设计与制作实用教程(第3版)
  • 建设网站那家好网络服务器的功能是
  • 兰州企业网站建设桂林 网站 制作
  • 网站跳转微信链接易经网站开发公司
  • 某网站seo策划方案做微信充值网站
  • 零售客户电商网站wordpress后台改中文
  • 东丽区做网站免费注册个人电子邮箱
  • 商贸公司寮步网站建设极致发烧外贸网站知名做外链
  • 如何查看网站是否降权企业网站功能模块设计
  • 手机网站列表 教程dz建站与wordpress
  • 移动网站建设模板阿里云企业网站建设教程
  • 南通快速建站公司网站怎么做跳转安全
  • 学习做网站难吗北京有限公司
  • 江苏网站建设效果flash网站标题和网址
  • 网站建设的主要内容包括wordpress 评论可见
  • 手机网站开发做烧烤的网站
  • 网站制作软件都是什么wordpress 学校主题
  • 桂林网站制作怎么给网站做背景
  • 寮步网站建设哪家好图片素材网站怎么做
  • 工商银行门户网站是什么意思北京seoqq群
  • 上市公司网站设计推广发帖网站
  • 果洛电子商务网站建设小程序的类型有哪些