Ubuntu部署tomcat及基本配置

文章目录

  • 1、tomcat的安装
  • 2、tomcat基本配置

1、tomcat的安装

//安装java环境
tomcat本身是一个Java程序,所以必须要有Java的的运行状态!

qinziteng@tomcat:~$ java   ##执行java可以查看java的一些安装包

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless   

qinziteng@tomcat:~$ sudo apt install openjdk-8-jre-headless 

qinziteng@tomcat:~$ java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-8u282-b08-0ubuntu1~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

//下载对应版本tomcat包
tomcat官网:https://tomcat.apache.org/
在这里插入图片描述
在这里插入图片描述或者使用wget下载

qinziteng@tomcat:~$ sudo wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.65/bin/apache-tomcat-8.5.65.tar.gz

下载好之后解压缩

qinziteng@tomcat:~$ tar zxf apache-tomcat-8.5.65.tar.gz 

qinziteng@tomcat:~$ sudo mv apache-tomcat-8.5.65 /usr/local/tomcat
qinziteng@tomcat:~$ ls /usr/local/tomcat/
bin           conf             lib      logs    README.md      RUNNING.txt  webapps
BUILDING.txt  CONTRIBUTING.md  LICENSE  NOTICE  RELEASE-NOTES  temp         wor

//优化路径并开启

qinziteng@tomcat:~$ sudo ln -s /usr/local/tomcat/bin/*  /usr/local/sbin/
qinziteng@tomcat:~$ startup.sh start 
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 CATALINA_OPTS:   
Tomcat started.

qinziteng@tomcat:~$ netstat -anput |  grep 8080
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::8080                 :::*                    LISTEN      3860/java           

启动参数:

startup.sh start //启动
shutdown.sh //关闭

catalina.sh stop //启动
catalina.sh start //关闭

//关闭防火墙

qinziteng@tomcat:~$ sudo ufw disable 

浏览器访问
在这里插入图片描述

2、tomcat基本配置

//更改端口号

qinziteng@tomcat:~$ vim /usr/local/tomcat/conf/server.xml 
	.......

  

重启tomcat服务

qinziteng@tomcat:/usr/local/tomcat/bin$ shutdown.sh 
qinziteng@tomcat:/usr/local/tomcat/bin$ startup.sh 

//更改网站目录

qinziteng@tomcat:~$ vim /usr/local/tomcat/conf/server.xml 
	.......
	
      

创建网站家目录

qinziteng@tomcat:~$ sudo mkdir /opt/www/ROOT -p

注意ROOT一定要是大写!!
重启tomcat服务

qinziteng@tomcat:/usr/local/tomcat/bin$ shutdown.sh 
qinziteng@tomcat:/usr/local/tomcat/bin$ startup.sh

你可能感兴趣的:(java,tomcat,ubuntu,java,搜索引擎,开发语言)