对于web服务的开启的判断有以下几种常用方法:
1、端口查看:
本地:ss,netstat,lsof
示例一: ss:查看80端口是否处于监听状态 [root@gw oldboy]# ss -an|grep 80 LISTEN 0 511 :::80 :::* 示例二: netstat:查看80端口/httpd服务是否开启 [root@gw oldboy]# netstat -lntup|grep 80 tcp 0 0 :::80 :::* LISTEN 2317/httpd [root@gw oldboy]# netstat -lntup|grep httpd tcp 0 0 :::80 :::* LISTEN 2317/httpd 示例三: lsof:查看80端口是否处于 [root@gw oldboy]# lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 2317 root 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2320 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2321 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2322 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2323 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2324 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2325 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2326 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN) httpd 2327 apache 4u IPv6 13199 0t0 TCP *:http (LISTEN)
远程:nmap
示例一: nmap:检测端口开启状态 [root@niaoyun ~]# nmap 192.168.1.21 -p 80 Starting Nmap 5.51 ( http://nmap.org ) at 2015-08-30 21:59 CST Nmap scan report for 192.168.1.21 Host is up (0.00013s latency). PORT STATE SERVICE 80/tcp closed http <== 注意这里 MAC Address: 00:0C:29:19:FC:7D (VMware) Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
2、本地进程数:
[root@niaoyun ~]# ps -ef|grep httpd root 1249 1 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1251 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1252 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1253 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1254 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1255 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1256 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1257 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd apache 1258 1249 0 22:05 ? 00:00:00 /usr/sbin/httpd root 1260 1117 0 22:05 pts/0 00:00:00 grep httpd [root@niaoyun ~]# ps -ef|grep httpd|wc -l 10
3、header状态值:
[root@niaoyun ~]# curl -I 192.168.1.20 HTTP/1.1 200 OK Date: Sun, 30 Aug 2015 14:16:55 GMT Server: Apache/2.2.15 (CentOS) Last-Modified: Sun, 30 Aug 2015 14:16:23 GMT ETag: "5fda3-13-51e87f62ea815" Accept-Ranges: bytes Content-Length: 19 Connection: close Content-Type: text/html; charset=UTF-8 [root@niaoyun ~]# curl -I -s 192.168.1.20|head -1 HTTP/1.1 200 OK
4、URL(wget,curl)模拟用户的方式:
示例一: wget:爬虫测试 [root@niaoyun ~]# wget --spider --timeout=10 192.168.1.20 Spider mode enabled. Check if remote file exists. --2015-08-30 22:23:34-- http://192.168.1.20/ Connecting to 192.168.1.20:80... connected. HTTP request sent, awaiting response... 200 OK Length: 19 [text/html] Remote file exists and could contain further links, but recursion is disabled -- not retrieving.
转载于:https://blog.51cto.com/maocong/1689980