Sun Solaris 9 DNS + apache + tomcat 的配置笔记
我自己先把我做的贴出来晒一晒吧!? 请大家多多指教了!
一. 软件包的安装和配置:
下载地址及参考文档
apache-2.2.4-sol9-sparc-local.gz
libgcc-3.4.6-sol9-sparc-local.gz
bind-9.4.1pl1-sol9-sparc-local.gz
libiconv-1.11-sol9-sparc-local.gz
expat-1.95.5-sol9-sparc-local.gz
openssl-0.9.8e-sol9-sparc-local.gz
gcc-3.4.6-sol9-sparc-local.gz
zlib-1.2.3-sol9-sparc-local.gz
bash-2.05# pkgadd -d apache-2.2.4-sol9-sparc-local -----如此把上面的软件逐个装好.
The following packages are available:
1 SMCap224 apache
(sparc) 2.2.4
Select package(s) you wish to process (or 'all' to process) ---照提示,安装好
关键的配置文件如下:
1. dns 的主配置文件.
bash-2.05# vi /usr/local/sbin/etc/named.conf -----加入以下内容
options {
directory "/usr/local/sbin/var/named";
forwarders { 210.21.4.130; 202.96.128.86; };
};
// // a caching only nameserver config
//
zone "." IN {
type hint;
file "named.ca";
};
zone "xiao.com" IN {
type master;
file "xiao.com.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "xiao.com.local";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.local";
allow-update { none; };
};
2. named.ca 的dns主机表文件.
bash-2.05# vi /usr/local/sbin/var/named/named.ca -----加入以下内容
;This is file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache .
"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Jan 29, 2004
; related version of root zone: 2004012900
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; operated by VeriSign, Inc.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
;
; operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; operated by ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
; End of File
3. 主机的反向解析 localhost.local
bash-2.05# vi /usr/local/sbin/var/named/localhost.local -----加入以下内容
$TTL 86400
@ IN SOA root. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS
213 IN PTR localhost.
4. 两个域名的反向解析 xiao.com.local
bash-2.05# vi /usr/local/sbin/var/named/xiao.com.local -----加入以下内容
$TTL 86400
@ IN SOA ns.xiao.com. root.xiao.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS ns.xiao.com.
213 IN PTR mail.xiao.com.
213 IN PTR
5. 主机的正向解析 xiao.com.zone
bash-2.05# vi /usr/local/sbin/var/named/xiao.com.zone -----加入以下内容
$TTL 86400
@ IN SOA ns.xiao.com. root.xiao.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS
IN MX 10 mail.xiao.com.
www IN A 192.168.1.213
ns IN A 192.168.1.213
mail IN A 192.168.1.213
ftp IN A 192.168.1.213
二. 说明几点.
1. 有关apache的
a . apache 直接装好了,就能运行起来的. 如有需要编辑 bash-2.05# vi /usr/local/apache2/conf/httpd.conf
b . 运行脚本:命令后面加相关的参数.有问题看帮助,和用 tail /var/adm/messages 查看相关的错误信息.
bash-2.05# /usr/local/apache2/bin/apachectl 看以下的运行参数.
Usage: /usr/local/apache2/bin/httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
-D name : define a name for use in directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-e level : show startup errors of level (see LogLevel)
-E file : log startup errors to file
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled in modules
-L : list available configuration directives
-t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
-S : a synonym for -t -D DUMP_VHOSTS
-t -D DUMP_MODULES : show all loaded modules
-M : a synonym for -t -D DUMP_MODULES
-t : run syntax check for config files
c. 查看端口,这里没有连接网线, 所以下面监听没有显示 IP 地址了. 端口是起来了.
bash-2.05# /usr/local/apache2/bin/apachectl -k restart ---重启
httpd not running, trying to start
bash-2.05# netstat -anv | grep 80
*.32780 Idle
*.80
*.80
*.80
2 有关 DNS 的 named
a. 安装好named文件之后,默认在/usr/local/sbin,有手动 mkdir 生成三个目录,var; run; etc 三个目录放相应的配置文件.
bash-2.05# mkdir -p /usr/local/sbin/var/named ----创建一个var 和 named 的目录
bash-2.05# mkdir /usr/local/sbin/run ------创建一个run的目录
bash-2.05# mkdir /usr/local/sbin/etc -----创建一个etc的文件目录.
bash-2.05# cat /usr/local/sbin/var/named-------这下面的四个文件对应于(真实的路径)/usr/local/sbin/etc/named.conf里的.
localhost.local named.ca xiao.com.local xiao.com.zone
bash-2.05# ln -s /usr/local/sbin/etc/named.conf /etc/named.conf ----做个软链接.
bash-2.05# ls -l /usr/local/sbin/etc/named.conf -----查看
lrwxrwxrwx 1 root other 30 Sep 10 14:01 /etc/named.conf -> /usr/local/sbin/etc/named.conf
bash-2.05# vi /etc/resolv.conf -------创建一个主机名解析的文件, 加入下面的内容.
nameserver 192.168.1.213
bash-2.05# touch /usr/local/sbin/run/named.pid -----生成一个运行用的进程文件.
b. 运行
另外也可以运行/usr/sbin/in.named 检查 DNS 的状况. 加参数 -v 可以查看dns的版本
bash-2.05# /usr/local/sbin/named -----直接运行就好了.
bash-2.05# netstat -anv | grep 53 -----查看端口有没有监听到, 有的话就运行了.
127.0.0.1.53 Idle
192.168.1.213.53 Idle
127.0.0.1.53 Idle
192.168.1.213.53 Idle
127.0.0.1.53 Idle
192.168.1.213.53 Idle
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 IDLE
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
127.0.0.1.53
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
192.168.1.213.53
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
C. 有关的其他文件
bash-2.05# vi /etc/host
hostname.le0 hosts
bash-2.05# vi /etc/hosts ----主机域名解析
#
# Internet host table
#
127.0.0.1 localhost
192.168.1.213 xiao.com
bash-2.05# vi /etc/nodename -----主机名
xiao.com
bash-2.05# vi /etc/hostname.le0 ----这里就是主机名了, 不是IP地址.
xiao.com
bash-2.05# vi /etc/nsswitch.conf
#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.
passwd: files
group: files
hosts: files dns --------这里加上 dns
ipnodes: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
# At present there isn't a 'files' backend for netgroup; the system will
# figure it out pretty quickly, and won't use netgroups at all.
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files
printers: user files
auth_attr: files
prof_attr: files
project: files
bash-2.05# cat /etc/netmasks ------子网掩码
#
# The netmasks file associates Internet Protocol (IP) address
# masks with IP network numbers.
#
# network-number netmask
#192.168.1.13/24
# The term network-number refers to a number obtained from the Internet Network
# Information Center.
#
# Both the network-number and the netmasks are specified in
# "decimal dot" notation, e.g:
#
# 128.32.0.0 255.255.255.0
#
192.168.1.0 255.255.255.0
bash-2.05# cat /etc/defaultrouter -------网关
192.168.0.3
d. 测试
bash-2.05# nslookup
Default Server: mail.xiao.com
Address: 192.168.1.213
>
Server: mail.xiao.com
Address: 192.168.1.213
Name:
Address: 192.168.1.213
> mail.xiao.com
Server: mail.xiao.com
Address: 192.168.1.213
Name: mail.xiao.com
Address: 192.168.1.213
> 192.168.1.213
Server: mail.xiao.com
Address: 192.168.1.213
Name: mail.xiao.com
Address: 192.168.1.21
d. 运行环境:
这个整个的配置文档,只是个实验环境,在安全上还欠缺!! 不能照搬, 需要转载,请注明出处!!
bash-2.05# uname -a
SunOS xiao.com 5.9 Generic_112233-05 sun4u sparc SUNW,Ultra-1
3 tomcat 和 apache 的整合:
a tomcat 运行的条件
(1)首先DNS 53号端口和 apache 80号端口要运行起来. 用以下两条命令检查一下看看是否在运行.有下面的字样表示在运行了.
bash-2.05# netstat -anv |grep 53
127.0.0.1.53 Idle
192.168.0.213.53 Idle
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 LISTEN
*.* 0 00000000 00000000 49152 00000000 00000000 3375 536 IDLE
bash-2.05# netstat -anv |grep 80
*.32780 Idle
*.32780
*.80
*.8080
*.8009
127.0.0.1.8005
*.80
(2)设定好一个 java 和 tomcat 的运行环境 ( 里面好些和后面的步骤有关 , 我是已经做好了, cat 给大家看的 .我会加以说明的 )
bash-2.05# cat /etc/rc3.d/S91tomcat
#!/sbin/sh
JAVA_HOME=/usr/jdk/jdk1.6.0_03
CLASSPATH=.:/usr/jdk/jdk1.6.0_03/bin:/usr/jdk/jdk1.6.0_03/jre/lib
export JAVA_HOME CLASSPATH
CATALINA_HOME=/usr/local/apache2/tomcat
CATALINA_BASE=/usr/local/apache2/tomcat
export CATALINA_HOME CATALINA_BASE
/usr/local/apache2/tomcat/bin/startup.sh
bash-2.05# vi /etc/profile ----为了保险起见, 在这个配置文件中加入tomcat; java 的环境变量.
JAVA_HOME=/usr/jdk/jdk1.6.0_03
CLASSPATH=.:/usr/jdk/jdk1.6.0_03/bin:/usr/jdk/jdk1.6.0_03/jre/lib
export JAVA_HOME CLASSPATH ---JAVA 的运行环境变量
CATALINA_HOME=/usr/local/apache2/tomcat
CATALINA_BASE=/usr/local/apache2/tomcat
export CATALINA_HOME CATALINA_BASE ----TOMCAT 的运行环境变量
(3)在sun solaris 9 里面您在安装 apache 的时候其实就已经安装好了tomcat, 默认是在 /var 和 /us的下面; 只不过版本有点就了. 在这里我把以前的tomcat删了, 或者把他改为别的名字, 这样的话, 如果做不好还可以还原回去的; 在这里我把原来的 apache 和 tomcat 都不要了, 都改名, 让他们不起作用.
bash-2.05# /usr/apache/tomcat 改为: bash-2.05# /usr/apache-old/tomcat-old
bash-2.05# /var/apache/tomcat 改为: bash-2.05# /var/apache-old/tomcat-old
(4)软件包的下载:
a. java 软件
下载这包(32位): jdk-6u3-solaris-sparc.tar.Z
解压到 /tmp 有如下软件:
bash-2.05# uncompress jdk-6u3-solaris-sparc.tar.Z
bash-2.05# tar xvf jdk-6u3-solaris-sparc.tar
bash-2.05# ls
COPYRIGHT SUNWj6rt
LICENSE SUNWjavadb-client
README.html SUNWjavadb-common
SUNWj6cfg SUNWjavadb-core
SUNWj6dev SUNWjavadb-demo
SUNWj6dmo SUNWjavadb-docs
SUNWj6jmp SUNWjavadb-javadoc
SUNWj6man
bash-2.05# dpkgadd ./SUNWj6cfg 一个一个地把解压出来的文件包给安装好.
bash-2.05# java -version 查看版本.
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
bash-2.05# rm -r /usr/java j2se java1.2 删除以前老的有关JAVA的目录.
bash-2.05# pwd 在这个目录, 做个软链接.
/usr
bash-2.05# ln -s jdk/instances/jdk1.6.0 java
bash-2.05# cd /usr/bin 在这个目录删除以下原来的链接目录, 然后重新指定新的.
bash-2.05# rm -r jar java javadoc javap jarsigner javac javah javaws jdb jcontrol
bash-2.05# ln -s /usr/jdk/instances/jdk1.6.0/bin/java java 剩下的9个接着做好.
bash-2.05# ls -l ja*
lrwxrwxrwx 1 root other 35 Oct 19 16:57 jar -> /usr/jdk/instances/jdk1.6.0/bin/jar
lrwxrwxrwx 1 root other 41 Oct 19 17:00 jarsigner -> /usr/jdk/instances/jdk1.6.0/bin/jarsigner
lrwxrwxrwx 1 root other 36 Oct 19 16:58 java -> /usr/jdk/instances/jdk1.6.0/bin/java
lrwxrwxrwx 1 root other 37 Oct 19 16:59 javac -> /usr/jdk/instances/jdk1.6.0/bin/javac
lrwxrwxrwx 1 root other 39 Oct 19 17:03 javadoc -> /usr/jdk/instances/jdk1.6.0/bin/javadoc
lrwxrwxrwx 1 root other 37 Oct 19 16:59 javah -> /usr/jdk/instances/jdk1.6.0/bin/javah
lrwxrwxrwx 1 root other 37 Oct 19 17:00 javap -> /usr/jdk/instances/jdk1.6.0/bin/javap
lrwxrwxrwx 1 root other 38 Oct 19 17:00 javaws -> /usr/jdk/instances/jdk1.6.0/bin/javaws
bash-2.05# ls -l jd*
lrwxrwxrwx 1 root other 35 Oct 19 17:02 jdb -> /usr/jdk/instances/jdk1.6.0/bin/jdb
bash-2.05# ls -l jco*
lrwxrwxrwx 1 root other 40 Oct 19 17:01 jcontrol -> /usr/jdk/instances/jdk1.6.0/bin/jcontrol
b. tomcat 软件
下载包: apache-tomcat-6.0.14.tar.gz 这里解压到 /usr/local/apache2/ 下.
JDK配置好后, tomcat 几乎不用做其他的配置改动, 就可以运行了. 当然您要更高级的运用, 就的
配置好了. 当然要设置好它的运行环境了. 这个上面一开始就讲过了, 这里再说明一下:
bash-2.05# cat /etc/rc3.d/S91tomcat --设置好开机系统级别3的时候, 就自动运行.( 注意脚本要以S开头,后跟数字加名字的格式 ).
#!/sbin/sh
JAVA_HOME=/usr/jdk/jdk1.6.0_03
CLASSPATH=.:/usr/jdk/jdk1.6.0_03/bin:/usr/jdk/jdk1.6.0_03/jre/lib
export JAVA_HOME CLASSPATH -----设置好JAVA运行的环境变量
CATALINA_HOME=/usr/local/apache2/tomcat
CATALINA_BASE=/usr/local/apache2/tomcat
export CATALINA_HOME CATALINA_BASE -----设置好tomcat运行环境变量
/usr/local/apache2/tomcat/bin/startup.sh ----tomcat 运行脚本
bash-2.05# ls -l /etc/rc3.d/S91tomcat 这个脚本的属性 (注意)
-rwxr--r-- 1 root sys 178 Oct 24 15:45 /etc/rc3.d/S91tomcat
bash-2.05# /usr/local/apache2/tomcat/bin/startup.sh --启动脚本看看,会不会报错, 有错就改.这样就正常了.
Using CATALINA_BASE: /usr/local/apache2/tomcat
Using CATALINA_HOME: /usr/local/apache2/tomcat
Using CATALINA_TMPDIR: /usr/local/apache2/tomcat/temp
Using JRE_HOME: /usr/jdk/jdk1.6.0_03
bash-2.05# /usr/local/apache2/tomcat/bin/shutdown.sh --停止服务
Using CATALINA_BASE: /usr/local/apache2/tomcat
Using CATALINA_HOME: /usr/local/apache2/tomcat
Using CATALINA_TMPDIR: /usr/local/apache2/tomcat/temp
Using JRE_HOME: /usr/jdk/jdk1.6.0_03
在启动tomcat之后, 用命令看看端口是否起来了
bash-2.05# netstat -avn |grep 8080
*.8080 ------默认的端口已经起用了.
在另外的客户机上就能访问了, 正常的话, 就能看到一只猫咪了. 呵呵!
如果还需要更多的, 更高级的运用就要进一步配置tomcat了!
阅读(1942) | 评论(0) | 转发(0) |