利用花生壳+顶级域名+动态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下安装花生壳的方法:
1、安装说明(以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
2、花生壳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
保存退出
至此全部配置结束!重启服务器测试。