利用花生壳+顶级域名+动态IP+Tomcat简单架设自己的网站服务器
安装配置Tomcat 方法请参考 http://wenku.baidu.com/view/64c9d622192e45361066f5ea.html
或者百度搜索安装配置方法<本教程主要介绍利用花生壳解析顶级域名>
这个方法适合有顶级域名并且想用自己的个人宽带(IP经常变动)+个人电脑充当服务器.另外还适合想搭建服务器给别人访问使用的.
1.一般情况下因为IP的经常变动,所以并不适合绑定顶级域名,因为每次你IP变动都需要重新绑定一次域名,而绑定域名在这种情况下一般是设置A记录,而 A记录在DNS上生效最快也要几小时,所以你更换IP后,通过顶级域名访问会有几个小时不能访问你的服务器,而这几个小时的不能访问则会造成您客户的大量流失.
2.那使用花生壳本地建站吧,可惜花生壳只提供免费的二级域名绑定动态IP功能,想使用他的顶级域名绑定IP功能不是不行,不过需要在他们那里买域名并且还要交纳一定的域名绑定动态IP服务费.这对于我们来说是不可接受的
那么到底有没有办法让我们免费使用顶级域名绑定动态IP功能呢?肯定是有的,不然我在这里废话这么多干嘛~
方法一:
1.下载花生壳,(或者不用花生壳也可以,前提是你的IP比较固定)并申请个花生壳护照,然后登陆花生壳客户端,在上面随便申请个免费的vicp.net 或者xicp.net形式的二级域名,比如我申请了bnnb.xicp.net,然后会让你确认是不是绑定到花生壳客户端,确定就可以了,申请成功后重启一下你电脑上的花生壳客户端,这样你刚刚申请的二级域名就绑上了你电脑现在的IP
2.关键步骤,这一步就是顶级域名能不能绑上动态IP的关键,进入你的顶级域名DNS控制面板,然后设置域名的解析方式为cname,然后把你的域名www.xxx.com利用 cname指向你刚申请的花生壳二级域名,把所有你要用到的二级域名都用cname指向这个二级域名
3.OK域名设置完成.这样只要你每次更换IP重新启动一下花生壳,让花生壳的域名绑上新的IP(花生壳二级域名更换IP是马上更新的,可以马上使用),你的顶级域名也会马上对应更改.
方法二:就需要麻烦一点点而且需要小小的money,花生壳注册护照,注册顶级域名,如果已经有域名了的,可以先转移域名到花生壳进行动态解析,这样就完成了动态IP解析顶级域名的目的,下面就只需要在你的服务器上下载花生壳客户端安装好花生壳登陆你的护照上去即可。
以下是在linux下安装花生壳的方法:
一、安装说明(以CentOS 5为例)
1、安装必要的开发包
[root@localhost ~]# yum install gcc gcc-c++ autoconf automake
2、下载phddns-2.0.2.16556.tar.gz到某一个目录
[root@localhost ~]# wget http://download.oray.com/peanuthull/phddns-2.0.2.16556.tar.gz
3、解压所有文件
[root@localhost ~]# tar zxvf phddns-2.0.2.16556.tar.gz
4、进入目录并编译
[root@localhost ~]# cd phddns-2.0.2.16556
[root@localhost phddns-2.0.2.16556]# aclocal
[root@localhost phddns-2.0.2.16556]# autoconf
[root@localhost phddns-2.0.2.16556]# automake
[root@localhost phddns-2.0.2.16556]# ./configure
[root@localhost phddns-2.0.2.16556]# make
[root@localhost phddns-2.0.2.16556]# cd src
[root@localhost src]# ls -l phddns
-rwxr-xr-x 1 root root 80968 Aug 2 11:18 phddns
5、执行编译好的程序并配置(默认使用/etc/phlinux.conf,如果不存在这个文件则自动进入交互配置)
[root@localhost src]# ./phddns
输入服务器地址,如无特殊情况可使用默认值
Enter server address(press ENTER use phlinux3.oray.net):
输入您的Oray帐号名称
Enter your Oray account:
对应的Oray帐号密码
Password:
选择帮定的网卡,如无特殊,默认即可
Network interface(s):
eth0:192.168.141.18
lo:127.0.0.1
Choose one(default eth0):
选择日志保存到哪个文件
Log to use(default /var/log/phddns.log):
保存配置文件,选择yes则直接保存到/etc/phlinux.conf,输入other可以指定文件
Save to configuration file (/etc/phlinux.conf)?(yes/no/other):
接下来程序将已交互模式开始运行
192.168.141.18
NIC bind success
OnStatusChanged okConnecting
OnStatusChanged okDomainListed
OnDomainRegistered skyvense22.gicp.net
OnStatusChanged okDomainsRegistered
UserType: 0
看到上面这些就表示登录成功,这个时候可以按ctrl+c先退出程序
6、将phddns拷贝到你希望的位置
[root@localhost src]# cp phddns /usr/bin/
7、以后台模式启动花生壳并检查运行情况
[root@localhost ~]# /usr/bin/phddns -c /etc/phlinux.conf -d
phlinux started as daemon!
[root@localhost ~]# tail /var/log/phddns.log
2011/08/02 11:28:58.256| ExecuteUpdate OK, BeginKeepAlive!
2011/08/02 11:29:59.354| SendKeepAlive() 8208
2011/08/02 11:30:00.355| RecvKeepaliveResponse() Data comes, OPCODE:8272
2011/08/02 11:30:00.356| Keepalive response received, client ip: 116.231.123.96
2011/08/02 11:31:00.447| SendKeepAlive() 8208
2011/08/02 11:31:01.450| RecvKeepaliveResponse() Data comes, OPCODE:8272
2011/08/02 11:31:01.450| Keepalive response received, client ip: 116.231.123.96
8、退出花生壳
查看进程ID
[root@localhost ~]# ps -A | grep phddns
13731 ? 00:00:00 phlinux
让后台进程退出
[root@localhost ~]# kill -9 13731
9、将花生壳加到系统启动时运行
[root@localhost ~]# vi /etc/rc.local
在文件的末尾加上一行:/usr/bin/phddns -c /etc/phlinux.conf -d
二、花生壳Linux版本命令行参数说明
[root@localhost ~]# /usr/bin/phlinux -h
Peanuthull Linux-core 2.0 by oray.com, copyright 2011
Peanuthull Linux-core Help
--first-run
-f, run for the first time
用于首次启动时配置参数
--interact
-i, run as interactive mode
program will request for necessary parameters.
this mode will automatically enabled at first running,
or your configuration file has been lost.
启动交互模式
--daemon
-d, run as a daemon
program will quit after put itself to background,
and continue running even you logout,
you can use kill -9 <PID> to terminate.
后台模式
--config
-c, run with configuration file
program will run with the file
指定使用哪一个配置文件
--user
-u, run as the user
program will run as the user
以指定用户启动后台进程
--help
-h, print this screen.
Please visit http://www.oray.com for detail.
Debian/linux下安装花生壳
1.首先安装:
lxq007:~# aptitude install libstdc++5
2.然后下载花生壳客户端软件包
lxq007:~# wget www.oray.cn/PeanutHull/Down/phlinux10all.tar.gz
lxq007:~# tar zxvf phlinux10all.tar.gz
lxq007:~# cd phlinux_package/
lxq007:~/phlinux_package# ls
phlinux-1.0-install.fc5.tar.gz phlinux-1.0-install.redhat.tar.gz
phlinux-1.0-install.freebsd.4.1.tar.gz phlinux-1.0-install.suse9.0.tar.gz
phlinux-1.0-install.freebsd.5.4.tar.gz phlinux-1.1-install.ubuntu.8.04.tar.gz
phlinux-1.0-install.freebsd.6.0.tar.gz
lxq007:~# tar zxvf phlinux-1.0-install.redhat.tar.gz
lxq007:~# cd phlinux_install/
lxq007:~# ./install.sh
会出现下面信息:
Making directory /usr/local/phlinux...
Copying data...
Runing phlinux for first configuration...
Peanuthull Linux-core 1.0 by oray.net, copyright 2005
No user configuration found, entering interactive mode automatically!
Peanuthull Linux-core Interactive startup.
Please input service address(press ENTER use phservice2.oray.net): phservice2.oray.net
Note: Server address will automatically be retrieved by webservice!
this is just a backup address while you cannot connect webservice.
Please input server address(press ENTER use PH031.Oray.Net): PH031.Oray.Net#
Please input username(press ENTER use ): lxq007 #此处提示输入您的花生护照登陆名
Please input password: #此处提供输入花生护照登陆密码
Save to configuration file (/etc/phlinux.conf)?(yes/no): yes
以上操作完成,系统将自动登录花生壳服务器,用户可以通过web方式查看当前花生壳客户端的运行状态.
花生壳客户端使用 6160端口提供web检测服务,例如
http://192.168.0.1:6160/
此监测页面将完全的反应当前花生壳的运行状态.
3.其他
重新以互动设置模式运行程序配置
#/usr/local/phlinux/phlinux-i
后台进程模式运行
#/usr/local/phlinux/phlinux-d
用ps-A查看所有进程列表,记住phlinux的pid,再使用kill-9关闭
手动修改登陆的用户名及密码
您可以直接编辑/etc/phlinux.conf文件,对登陆用户名及密码进行修改
其他LINUX版本安装花生壳方法:
使用附件中花生壳安装包、拷贝到Linux任意一个目录,例如下图:
然后打开终端运行 install.sh 命令进行自动安装即可
<注意:如果提示权限不够,请手动给安装目录授予读写权限,否则无法安装成功>
最后就是让服务器 启动时候自动 运行 tomcat 和 花生壳 了。
我们最简单的方法就是通过startup.sh来自动启动Tomcat,编辑vi /etc/rc.d/rc.local
文件最后增加内容(假设JDK目录是/usr/java,Tomcat目录是/usr/local/tomcat)
export JDK_HOME=/usr/java/jdk1.7.0
export JAVA_HOME=/usr/java/jdk1.7.0
/usr/local/tomcat/bin/startup.sh
/usr/local/phlinux/phlinux -d
保存退出
至此所有配置结束!重启服务器测试。