Install JDK and Tomcat on Linux
1. Download the installation package
- Download JDK_8 , because when downloading JDK, you need to register to download, choose the corresponding system versionxxxx.tar.gz
- Download Tomcat_8 , select Coretar.gz
2. Install JDK
- Upload the JDK to
/usr/local/jdk/
the directory .
- Unzip the installation package
# 解压 jdk 安装包
[root@localhost jdk] tar -zxvf jdk-8u351-linux-x64.tar.gz
- Configure environment variables
# 打开配置环境变量的文件
[root@localhost jdk]# vim /etc/profile
# 点击 i,插入以下四行内容
JAVA_HOME=/usr/local/jdk/jdk1.8.0_351
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
# 输入以上内容后,点击 esc,然后点击英文冒号,在输入wq
# 刷新配置
[root@localhost jdk] source /etc/profile
# 查看Java版本
[root@localhost jdk] java -version
3. Install Tomcat
- Upload Tomcat to
/usr/local/
the directory .
- Unzip the installation package
# 解压 tomcat 安装包
[root@localhost local] tar -zxvf apache-tomcat-8.5.83.tar.gz
- enable tomcat
# 进入到 tomcat 的 bin 下
[root@localhost ~] cd /usr/local/apache-tomcat-8.5.83/bin
# 启用 tomcat
[root@localhost bin] ./start.sh
4. Access via browser
At this time, visit the tomcat of linux through the local browser. If the tomcat page can be displayed, the configuration is successful. Enter the IP address of linux in the browser, and the port is 8080, which is the default URL of tomcat.
5. Other configurations of tomcat
- close tomcat
# 在 /usr/local/apache-tomcat-8.5.83/bin 目录下
[root@localhost bin] ./shutdown.sh
- Configure the port of tomcat
# 在 /usr/local/apache-tomcat-8.5.83/conf 下,修改 server.xml 文件
[root@localhost conf] vim server.xml
http 访问端口:
Shutdown 端口:
JVM启动端口:
- Configure the application in tomcat.
# 将 .war 的包放到此目录中,war 会自动解压
[root@localhost conf] cd /usr/local/apache-tomcat-8.5.83/webapps
webapps -- web应用所在目录
|--- html, jsp, css, js文件等 -- 这些文件一般在web应用根目录下,根目录下的文件外界可以直接访问.
|--- WEB-INF 目录 -- java类、jar包、web配置文件存在这个目录下,外界无法直接访问,由web服务器负责调用.
|--- classes 目录 -- java类
|--- lib 目录 -- java类运行所需要的jar包
|--- web.xml 文件 -- web应用的配置文件