ubuntu/centos下使用xinetd

【简介】
参考百度百科
http://baike.baidu.com/link?url=nWkyOfMIk_rxHirveSXRc5qiqRxj_-wnFxh5-Pr5qXr9JC8l7TVrv7EWEpH8IsjP

centos在线安装
yum -y install xinetd

【知识点】
标准http响应文件内容
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Length: 0
Date: Wed, 27 Feb 2013 02:34:36 GMT

ubuntu下安装(系统级工具,一般不自定义安装)
apt-get install xinetd

【创建个服务脚本】
/root/shell/httpok.sh

#!/bin/sh

/bin/echo -e "HTTP/1.1 200 OK"
/bin/echo -e "Content-Type: text/plain"
/bin/echo -e "Content-Length: 18"
/bin/echo -e "Connection: close"
/bin/echo -e ""
/bin/echo -e "httpok is running."
/bin/echo -e ""

修改脚本权限(给user可执行权限)
chmod 755 /root/shell/httpok.sh

【创建xinetd服务】
vi /etc/xinetd.d/httpok
service my_httpok
{
flags = REUSE
socket_type = stream
#port = 9201
wait = no
user = root
server = /root/shell/httpok.sh
#log_on_failure += USERID
disable = no
#only_from = 192.168.5.0/24
#recommended to put the IPs that need to connect exclusively (security purposes)
}


【修改端口,方法有2种】
1.默认依赖/etc/services,此时/etc/xinetd.d/httpok这个文件配置的port无效,所以不需要配置
vi /etc/services
my_httpok 9201/tcp

2.解除依赖/etc/services
此时/etc/xinetd.d/httpok这个文件配置里需要加上
type = UNLISTED
port = 9201

【重启服务,测试端口访问】
service xinetd restart
curl http://127.0.0.1:9201/

【参考文章】
这2篇文章写的特别好,非常值得看
http://sopace.blog.51cto.com/1227753/324142
http://blog.chinaunix.net/uid-21411227-id-1826885.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值