一、Tomcat
基本配置
基本配置
1.为Tomcat提供SysV脚本
2.catalina 脚本讲解
3.telnet 登录管理Tomcat
4.配置Tomcat虚拟主机
5.Tomcat图形管理接口
2.catalina 脚本讲解
3.telnet 登录管理Tomcat
4.配置Tomcat虚拟主机
5.Tomcat图形管理接口
6.部署JSP网站案例
二、Nginx反向代理Tomcat服务器
1.Nginx将请求反向代理到后端Tomcat
2.Nginx将图片缓存到本地
3.Nginx将请求实现动静分离
2.Nginx将图片缓存到本地
3.Nginx将请求实现动静分离
注,实验环境说明,操作系统:CentOS 6.4 x86_64,软件版本:jdk-7u40、apache-tomcat-
7.0.42、Nginx-1.4.2,博客中所用到的软件请到这里下载:yunpan/QGBCLwrZnpLMS。
一、Tomcat 基本配置
1.为Tomcat提供SysV脚本
注,在上一篇博文中我们已经演示安装了Tomcat,这里我们就不在演示,不清楚的博友可以参考这篇博文,freeloda.blog.51cto/2033581/1299644,在上一篇博文中我们没有增加,SysV脚本,在这篇博文中我们来增加一下,下面我们就来具体演示一下。
[root@tomcat ~]# vim /etc/init.d/tomcat
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
CATALINA_HOME=/usr/local/tomcat #注意你的脚本路径
export CATALINA_HOME
# export CATALINA_OPTS="-Xms128m -Xmx256m"
exec $CATALINA_HOME/bin/catalina.sh $*
export CATALINA_HOME
# export CATALINA_OPTS="-Xms128m -Xmx256m"
exec $CATALINA_HOME/bin/catalina.sh $*
下面我们来增加执行权限,并加入服务列表设置开机自启动,
[root@tomcat ~]# chmod +x /etc/init.d/tomcat
[root@tomcat ~]# chkconfig --add tomcat
[root@tomcat ~]# chkconfig tomcat --list
[root@tomcat ~]# chkconfig --add tomcat
[root@tomcat ~]# chkconfig tomcat --list
tomcat 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
下面我们来启动一下Tomcat并测试一下,
[root@tomcat ~]# service tomcat start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
查看一下启动的端口号,
[root@tomcat ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1044/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1121/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 12988/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 13053/sshd
tcp 0 0 :::8080 :::* LISTEN 13088/java
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1044/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1121/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 12988/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 13053/sshd
tcp 0 0 :::8080 :::* LISTEN 13088/java
tcp 0 0 :::22 :::* LISTEN 1044/sshd
tcp 0 0 ::1:25 :::* LISTEN 1121/master
tcp 0 0 ::1:6010 :::* LISTEN 12988/sshd
tcp 0 0 ::1:6011 :::* LISTEN 13053/sshd
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 13088/java
tcp 0 0 :::8009 :::* LISTEN 13088/java
tcp 0 0 ::1:25 :::* LISTEN 1121/master
tcp 0 0 ::1:6010 :::* LISTEN 12988/sshd
tcp 0 0 ::1:6011 :::* LISTEN 13053/sshd
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 13088/java
tcp 0 0 :::8009 :::* LISTEN 13088/java
用浏览器访问一下,
好了,到这里Tomcat的SysV脚本增加完成,下面我们来说一下catalina脚本。
2.catalina 脚本讲解
首先我们来查看一下这个脚本,
[root@tomcat bin]# catalina.sh -h
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_40
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Usage: catalina.sh ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_40
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Usage: catalina.sh ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina, waiting up to 5 seconds for the process to end
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
nginx和apache区别 configtest Run a basic syntax check on&l - check exit code for result
version What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined
stop n Stop Catalina, waiting up to n seconds for the process to end
stop -force Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
nginx和apache区别 configtest Run a basic syntax check on&l - check exit code for result
version What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论