1.安装jdk
a)下载jdk1.6 (jdk-6u7-linux-i586.bin),于/data/software/ jdk-6u7-linux-i586.bin
b)授权给下载程序可以执行的权限
i.mv /data/software/jdk-6u7-linux-i586.bin/usr/local
ii.cd /usr/local
iii.chmod a+r jdk-6u7-linux-i586.bin
iv../ jdk-6u7-linux-i586.bin
v.ln –s jdk-6u7 jdk
c)配置java环境变量
i.直接编辑/etc/profile文件或者在/etc/profile.d/文件下新建java.sh文件,普通用户没有编辑权限,可以授权或者切换到root账户来编辑该文件.
1.vim /etc/profile.d/java.sh
在这里新建的java.sh文件里添加内容如下:
#set java 环境变量
JAVA_HOME=/usr/local/jdk
PATH=$PATH:/$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib
JRE_HOME=$JAVA_HOME/jre
export JAVA_HOMEPATH CLASSPATH JRE_HOME
ii.设置java和javac的符号连接,这里把默认的jdk(本系统默认是JDK1.4)改成刚新装的jdk1.6
#cd /usr/bin
#su root
#ln –s –f /usr/local/jdk/jre/bin/java
#ln –s –f/usr/local/jdk/bin/javac
2.JDK1.6安装完毕!进行tomcat安装
a)下载tomcat6(apache-tomcat-6.0.18.tar.gz),于/data/software/apache-tomcat-6.0.18.tar.gz
i.mv apache-tomcat-6.0.18.tar.gz/usr/local/
ii.tar –zxvf apache-tomcat-6.0.18.tar.gz
iii.ln –s apache-tomcat-6.0.18tomcat
iv.ln –sf/usr/local/tomcat/bin/startup.sh /usr/bin/tomcat-up
v.ln –sf /usr/local/tomcat/bin/shutdown.sh/usr/bin/tomcat-down
b)配置环境变量
i.编辑刚新建的/etc/profile.d/java.sh文件(如果没有新建就编辑/etc/profile文件),添
加TOMCAT_HOME
TOMCAT_HOME=/usr/local/tomcat
export JAVA_HOMEPATH CLASSPATH JRE_HOME TOMCAT_HOME
c)Tomcat自启动
echo"/usr/local/tomcat/bin/startup.sh">>/etc/rc.d/rc.local
3.安装apache
a)3.安装APACHE2.2.6
1. 进入下载目录:
cd /home/wangnan/soft
2. 解压缩文件:
tar zxvf httpd-2.2.6.tar.gz
解压缩后生成httpd-2.2.6目录,为安装源文件目录
3. 进入安装源文件目录
cd httpd-2.2.6
4. 生成安装前的配置文件,这里的—prefix指定apache的安装将安装到:/usr/local/apache目录下
./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
5. 生成make文件,并安装:
make;make install
//////编译过程大概要十几分钟:(真慢///////////////////
完成之后:
echo "/usr/local/apache/bin/apachectlstart">>/etc/rc.d/rc.local
上面设置启动系统后,自启动APACHE。
可vi /etc/rc.d/rc.local查看:)
4.tomcat与apache相结合
a)安装mod_jk模块
i.cp mod_jk-1.2.26-httpd-2.2.6.so/url/local/apache22/modules/ //将模块文件放置到apache的模块目录
b)修改apache配置文件(在/url/local/apache22/conf/httpd.conf的最下面加入)
1.# cd /url/local/apache22/conf/
2.# cp -pf httpd.conf httpd.conf.bak
3.# vi httpd.conf
4.LoadModule jk_modulemodules/mod_jk-1.2.25-httpd-2.2.4.so
5.JkWorkersFile"/usr/local/tomcat/conf/workers.properties"
6.JkLogFile"/usr/local/tomcat/logs/mod_jk2.log"
7.JkLogLevel info
8.JkMount /*/servlet/* ajp13
9.JkMount /*.jsp ajp13
10.JkMount /*.do ajp13
11.AddType application/x-jsp .jsp
c)添加tomcat配置文件
1.# vi/usr/local/tomcat/conf/workers.properties
2.workers.tomcat_home=/usr/local/tomcat
3.workers.java_home=/usr/local/jdk
4.ps=\
5.worker.list=ajp13
6.worker.ajp13.port=8009
7.worker.ajp13.host=localhost
8.worker.ajp13.type=ajp13
9.worker.ajp13.lbfactor=1
5.测试安装
a)#echo $PATH
b)#echo $CLASSPATH
c)#echo $TOMCAT_HOME
d)#java –version
6.Linux系统开防火墙时自动开启相对应端口
a)即时生效,重启后失效的方法
i.#service iptables start
ii.#service iptables stop
b)重启后生效
i.#chkconfig iptables on
ii.#chkconfig iptables off
c)在开启防火墙时,做如下设置,开启相关端口
i.修改/etc/sysconfig/iptables文件,添加以下内容:
ii.-A RH-Firewall-1-INPUT -m state--state NEW -m tcp -p tcp --dport 23 -j ACCEPT
iii.检查端口是否启动
1.# netstat -anp | grep :8080 //检查tomcat是否启动