原创 linux 爬虫拨号服务器完整设置

[root@cloud ~]# cat /home/bh.sh 
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/sbin/ifconfig

/usr/sbin/adsl-stop
sleep 5
/usr/sbin/adsl-start
sleep 2
while true
do
if [ `/sbin/ifconfig|egrep ppp0|/usr/bin/wc -l` -gt 0 ];then
    echo "start php" >>/root/bh.log
    /usr/bin/php   /home/aa.php >>/root/bh.log
    echo "stop" >>/root/bh.log
    exit
else
    echo "$(date) wait" >>/root/bh.log
    sleep 1
fi
done

第一步设置拨号

CENTOS 系统 ADSL 拨号连接教程

1, 先连接进入到服务器

 

2. 设置ADSL 拨号

adsl-setup   输入回车

 

seth0   输入回车

DNS 直接回车就行, 如何知道也可以写上

密码直接输入两次

这里是否允许其它用户连接,输入 no

防火墙为里输入0

开机自动连接 yes

确认刚才所有的信息,没问题直接输入y回车

3 启动ADSL连接

adsl-start   回车

 

4. 简单验证下是不是能上外网

ping -c 3 www.baidu.com

第二步设置:安装代理软件.端口要和php的端口一致.默认8888,防火墙可开可不开

35 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
36 yum install -y tinyproxy
37 ls
38 vim /etc/tinyproxy/tinyproxy.conf
39 service tinyproxy restart
40 service tinyproxy enable
41 service enable tinyproxy
42 iptables -nL
43 service
44 service enable tinyproxy
45 service tinyproxy enable
46 chkconfig tinyproxy on
47 chkconfig --list-all|egrep proxy
48 chkconfig --list|egrep proxy

Allow 127.0.0.1   可以注释代表任意机器可以连,实际写爬虫服务器机器.

由于机器周换防火墙可开可不开.

curl -x 服务器ip:8888 httpbin.org/get 

返回origin的值为代理IP地址,表明tinyPoxy设置成功了.

[root@cloud home]# cat aa.php
<?php
$url = 'http://xx.xx.xx.xx:端口/ip?s=8888&p=8888';
file_get_contents($url);

猜你喜欢

转载自www.cnblogs.com/gaoyuechen/p/10897832.html
今日推荐