原帖 http://www.31sky.net/2011/03/30/272.html
很多网友都很需要本博客提供VPN服务功能的源码,本博客的这项服务的理念也是来自w0w.me,现在就将具体的架设过程记录下来,同大家一起分析,其实很简单,如果您是高手,你就不需要看了。 环境介绍: 本人有两台VPS,一台就是本博客所在的VPS(OpenVZ,我们假设为VPS1),另外一台专门用了提供PPTPd VPN服务的VPS(Xen,我们假设为VPS2),假设提供PPTP VPN服务的VPS的IP地址为123.123.123.123。 第一步 :在VPS2上安装PPTPd VPN 第二步 :在VPS2上安装expect,用于生产随机密码 第三步:在VPS2上安装httpd 第四步:在VPS2上的/root/目录下编写shell脚本,文件名为vpn.sh,用于自动更新密码,以下是脚本源码 第五步:设置crontab,每30分钟执行一次脚本 将以下代码加入crontab 至此VPS2上的设置已经完成,然后就是在vps1上部署,很简单,就是几行php代码,主要是设置循环倒计时的代码,至于页面的美化我就不写了: $file=”http://123.123.123.123/vpninfo.txt”; $filetext=file($file); $timestamp=mktime($filetext[3],$filetext[4],$filetext[5],$filetext[1],$filetext[2],$filetext[0]); $timestamp=$timestamp+1800; $year=date(“Y”,$timestamp); $month=date(“m”,$timestamp); $day=date(“d”,$timestamp); $hour=date(“H”,$timestamp); $min=date(“i”,$timestamp); $sec=date(“s”,$timestamp); ?> <html> <head> <meta http-equiv=”content-type” content=”text/html; charset=utf-8″ /> <title>Free VPN</title> <meta name=”description” content=”Free VPN” /> <meta name=”keywords” content=”Free VPN” /> </head> <body> <embed src=”http://www.clocklink.com/clocks/9001e-blue.swf?TimeZone=GMT0800&Target=<?=$year?>,<?=$month?>,<?=$day?>,<?=$hour?>,<?=$min?>,<?=$sec?>&Title=%E8%B7%9D%E4%B8%8B%E4%B8%80%E6%AC%A1%E6%9B%B4%E6%96%B0%E5%AF%86%E7%A0%81&Message=%E5%AF%86%E7%A0%81%E5%B7%B2%E6%9B%B4%E6%96%B0%EF%BC%8C%E8%AF%B7%E5%88%B7%E6%96%B0%EF%BC%81&” width=”320″ height=”20″ wmode=”transparent” type=”application/x-shockwave-flash”> </body> </html>
#chmod +x pptpd.sh
#./pptpd.sh
#service httpd start