最近要在Linux上安装Tomcat,记录下,内容比较简单
1.进入tomcat8的安装目录
List-1
root@iZwz9bjiawhqzfsklyht4rZ bin]# pwd/opt/app/tomcat8/bin[root@iZwz9bjiawhqzfsklyht4rZ bin]# ll总用量 836-rw-r--r-- 1 root root 34873 6月 29 22:43 bootstrap.jar-rw-r--r-- 1 root root 15912 6月 29 22:43 catalina.bat-rwxr-xr-x 1 root root 23353 6月 29 22:44 catalina.sh-rw-r--r-- 1 root root 1647 6月 29 22:44 catalina-tasks.xml-rw-r--r-- 1 root root 25145 6月 29 22:43 commons-daemon.jar-rw-r--r-- 1 root root 207125 6月 29 22:44 commons-daemon-native.tar.gz-rw-r--r-- 1 root root 2040 6月 29 22:43 configtest.bat-rwxr-xr-x 1 root root 1922 6月 29 22:44 configtest.sh-rwxr-xr-x 1 root root 8509 6月 29 22:44 daemon.sh-rw-r--r-- 1 root root 2091 6月 29 22:43 digest.bat-rwxr-xr-x 1 root root 1965 6月 29 22:44 digest.sh-rw-r--r-- 1 root root 3460 6月 29 22:43 setclasspath.bat-rwxr-xr-x 1 root root 3680 6月 29 22:44 setclasspath.sh-rw-r--r-- 1 root root 2020 6月 29 22:43 shutdown.bat-rwxr-xr-x 1 root root 2121 9月 26 22:08 shutdown.sh-rw-r--r-- 1 root root 2022 6月 29 22:43 startup.bat-rwxr-xr-x 1 root root 2165 9月 26 22:05 startup.sh-rw-r--r-- 1 root root 49038 6月 29 22:43 tomcat-juli.jar-rw-r--r-- 1 root root 408967 6月 29 22:44 tomcat-native.tar.gz-rw-r--r-- 1 root root 4586 6月 29 22:43 tool-wrapper.bat-rwxr-xr-x 1 root root 5495 6月 29 22:44 tool-wrapper.sh-rw-r--r-- 1 root root 2026 6月 29 22:43 version.bat-rwxr-xr-x 1 root root 1908 6月 29 22:44 version.sh
2.修改startup.sh
List-2
#set java environmentexport JAVA_HOME=/opt/app/jdk8export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH#tomcatexport TOMCAT_HOME=/opt/app/tomcat8exec "$PRGDIR"/"$EXECUTABLE" start "$@"
执行startup.sh,如下List-3,这样就启动了。
List-3
[root@iZwz9bjiawhqzfsklyht4rZ bin]# ./startup.shUsing CATALINA_BASE: /opt/app/tomcat8Using CATALINA_HOME: /opt/app/tomcat8Using CATALINA_TMPDIR: /opt/app/tomcat8/tempUsing JRE_HOME: /opt/app/jdk8/jreUsing CLASSPATH: /opt/app/tomcat8/bin/bootstrap.jar:/opt/app/tomcat8/bin/tomcat-juli.jarTomcat started.[root@iZwz9bjiawhqzfsklyht4rZ bin]#
3.修改shutdown.sh
List-4
#set java environmentexport JAVA_HOME=/opt/app/jdk8export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH#tomcatexport TOMCAT_HOME=/opt/app/tomcat8exec "$PRGDIR"/"$EXECUTABLE" stop "$@"[root@iZwz9bjiawhqzfsklyht4rZ bin]#
执行shutdown.sh,如下图List-5,这样就关闭了
List-5
[root@iZwz9bjiawhqzfsklyht4rZ bin]# ./shutdown.shUsing CATALINA_BASE: /opt/app/tomcat8Using CATALINA_HOME: /opt/app/tomcat8Using CATALINA_TMPDIR: /opt/app/tomcat8/tempUsing JRE_HOME: /opt/app/jdk8/jreUsing CLASSPATH: /opt/app/tomcat8/bin/bootstrap.jar:/opt/app/tomcat8/bin/tomcat-juli.jar[root@iZwz9bjiawhqzfsklyht4rZ bin]#
4.修改tomcat默认的端口
List-6
[root@iZwz9bjiawhqzfsklyht4rZ conf]# pwd/opt/app/tomcat/tomcat8/conf[root@iZwz9bjiawhqzfsklyht4rZ conf]# ll总用量 220drwxr-xr-x 3 root root 4096 9月 26 21:57 Catalina-rw------- 1 root root 13852 6月 29 22:44 catalina.policy-rw------- 1 root root 7499 6月 29 22:44 catalina.properties-rw------- 1 root root 1577 6月 29 22:44 context.xml-rw------- 1 root root 3387 6月 29 22:44 logging.properties-rw------- 1 root root 6458 9月 26 22:44 server.xml-rw------- 1 root root 2164 6月 29 22:44 tomcat-users.xml-rw------- 1 root root 2634 6月 29 22:44 tomcat-users.xsd-rw------- 1 root root 169566 6月 29 22:44 web.xml[root@iZwz9bjiawhqzfsklyht4rZ conf]#
修改List-5的server.xml,将port的值修改为其它值就可以了,默认值是8080
图4.1 修改port的值位8080
Reference: