[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
1, 先链接进入到服务器php
2. 设置ADSL 拨号vim
adsl-setup 输入回车bash
seth0 输入回车服务器
DNS 直接回车就行, 如何知道也能够写上curl
密码直接输入两次url
这里是否容许其它用户链接,输入 nospa
防火墙为里输入0代理
开机自动链接 yesrest
确认刚才全部的信息,没问题直接输入y回车code
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);