Linux下汤姆cat安装与安插,安装配置

作者: 金沙澳门官网  发布:2019-11-03

使用到的软件:apache-tomcat-7.0.8.tar.gz jdk-6u26-linux-x64.bin

本次安装使用的套件

# sh jdk-6u26-linux-x64.bin
# mv jdk1.6.0_26/ /usr/local/
# cd /usr/local/
# mv jdk1.6.0_26/  jdk

apache-tomcat-6.0.14.tar.gz
jdk-6u3-linux-i586-rpm.bin

#vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=:$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
# source /etc/profile
# echo $JAVA_HOME
/usr/local/jdk
# echo $CLASSPATH
:/usr/local/jdk/lib
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin:/usr/local/jdk/bin:/usr/local/jdk/bin

httpd-2.2.6.tar.gz
tomcat-connectors-1.2.26-src.tar.gz

# tar xf apache-tomcat-7.0.8.tar.gz -C /usr/local/
# cd /usr/local/
# mv apache-tomcat-7.0.8/ tomcat
# cd /usr/local/tomcat/bin
# ./startup.sh
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
# vim /usr/local/nginx/conf/nginx.conf
location ~ .jsp$ {
                proxy_pass ;
        }
//关于nginx的详细配置请参考
# cd /usr/local/tomcat/webapps/ROOT
# vim index.jsp
The time is: <%= new java.util.Date() %>
图片 1

安装、设置的前期准备

如果把nginx换成apache的话:

(1)、安装编译套件gcc

# yum install httpd -y
# mv mod_jk-1.2.31-httpd-2.2.x.so  /etc/httpd/modules         
//我这里用的是x86_64 的,一定要对应,要不服务起不起来
# vim /etc/httpd/conf.d/htp-jk.conf
LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.x.so
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
JkMount /*.do ajp13
AddType application/x­jsp .jsp图片 2

(2)、关闭系统默认的apache

[root@localhost ~]# /etc/init.d/httpd stop
[root@localhost ~]# chkconfig httpd off

1、安装配置JAVA

[root@localhost ~]# chmod a+x jdk-6u3-linux-i586.rpm.bin

[root@localhost ~]# ./jdk-6u3-linux-i586.rpm.bin (按照提示输入yes)

[root@localhost ~]# cd /usr/java/jdk1.6.0_03/bin/
[root@localhost bin]# ./java(检查一下)

[root@localhost ~]# vi /etc/profile(修改环境变量)
export JAVA_HOME=/usr/java/jdk1.6.0_03
export JRE_HOME=/usr/java/jdk1.6.0_03/jre

[root@localhost ~]# echo $JAVA_HOME(退出当前shell再次登录能成功执行者两条指令表示成功)
/usr/java/jdk1.6.0_03
[root@localhost ~]# echo $JRE_HOME
/usr/java/jdk1.6.0_03/jre

 

2、安装httpd

[root@localhost ~]# tar zxvf httpd-2.2.6.tar.gz

[root@localhost ~]# cd httpd-2.2.6
[root@localhost httpd-2.2.6]# ./configure

[root@localhost httpd-2.2.6]# make

[root@localhost httpd-2.2.6]# make install

[root@localhost httpd-2.2.6]# cd /usr/local/apache2/bin/
[root@localhost bin]# ./apachectl start
[root@localhost bin]# netstat -tulnp|grep 80(确保80端口正常开启)

测试在浏览器地址栏中输入 出现 It Works! 字样表示成功
3、安装tomact

[root@localhost ~]# tar -zxvf apache-tomcat-6.0.14.tar.gz
[root@localhost ~]# mv ~/apache-tomcat-6.0.14 /usr/local/
[root@localhost ~]# cd /usr/local/apache-tomcat-6.0.14/bin/
[root@localhost bin]# ./startup.sh (开启服务)
Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.14
Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.14
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.14/temp
Using JRE_HOME:       /usr/java/jdk1.6.0_03/jre

[root@localhost bin]# netstat -tulnp|grep 8080(检查确保服务运行)
tcp        0      0 :::8080                     :::*                        LISTEN      8699/java 

测试在IE地址栏中输入 出现带有小猫的页面表示成功

4、apache和tomcat的整合

[root@localhost ~]# tar zxvf tomcat-connectors-1.2.26-src.tar.gz

[root@localhost ~]# cd tomcat-connectors-1.2.26-src/native/

[root@localhost native]# ./configure --with-apxs=/usr/local/apache2/bin/apxs

[root@localhost native]#make

[root@localhost native]# cd apache-2.0/
[root@localhost apache-2.0]# cp mod_jk.so /usr/local/apache2/modules/

[root@localhost ~]# cd /usr/local/apache2/htdocs/
[root@localhost htdocs]# mkdir jsp/(建立此目录为了保存jsp文件)

[root@localhost htdocs]# cd jsp/(建立测试文档和目录)
[root@localhost jsp]# ll
total 16
-rw-r--r-- 1 root root 2065 Feb  2  2003 index.jsp
drwxr-xr-x 2 root root 4096 May 11 09:38 WEB-INFO
[root@localhost ~]# cd /usr/local/apache2/htdocs

[root@localhost htdocs]# ll
-rw-r--r-- 1 root root 2065 Feb  2  2003 index.jsp(建立测试主页)

[root@localhost ~]# cd /usr/local/apache2/conf
[root@localhost conf]# vim workers.properties (用户参数限定)
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300

[root@localhost conf]# vim mod_jk.conf (相关的用户日志文档、目录)
JkWorkersFile /usr/local/apache2/conf/workers.properties
JkLogFile /usr/local/apache2/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkMount /servlet/* worker1
JkMount /*.jsp worker1
[root@localhost ~]# cd /usr/local/apache2/conf/
[root@localhost conf]# vi httpd.conf (修改主配置档添加修改以下的部分)

<Directory "/usr/local/apache2/htdocs/jsp">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    XBitHack on
</Directory>
<Directory "/usr/local/apache2/htdocs/jsp/WEB-INFO">
    Order deny,allow
    Deny from all
</Directory>
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
<IfModule dir_module>
    DirectoryIndex index.html index.jsp
</IfModule>
[root@localhost ~]# cd /usr/local/apache-tomcat-6.0.14/bin/(重启tomcat)
[root@localhost bin]# ./shutdown.sh
[root@localhost bin]# ./startup.sh

[root@localhost ~]# cd /usr/local/apache2/bin/(重启apache)
[root@localhost bin]# ./apachectl restart
[root@localhost ~]# netstat -tulnp|grep 80(检查服务运行状态)
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      8699/java          
tcp        0      0 :::8009                     :::*                        LISTEN      8699/java          
tcp        0      0 :::8080                     :::*                        LISTEN      8699/java          
tcp        0      0 :::80                       :::*                        LISTEN      28016/httpd 

最后测试在IE地址栏中输入 不用加8080端口仍然可以正常显示jsp页面,tomcat的配置就成功了

图片 3

本文由金沙澳门官网送注册58发布于金沙澳门官网,转载请注明出处:Linux下汤姆cat安装与安插,安装配置

关键词: