Deepin 安装 tomcat
<h2 id="deepin-安装-tomcat9">Deepin 安装 tomcat9</h2><h4 id="一安装">一、安装</h4>
<pre><code class="language-shell">sudo apt install tomcat8 tomcat8-user tomcat8-admin tomcat8-docs tomcat8-examples
</code></pre>
<h4 id="二操作">二、操作</h4>
<pre><code class="language-shell">sudo systemctl start tomcat8
# 开启
sudo systemctl stop tomcat8
# 关闭
sudo systemctl restart tomcat8
# 重启
</code></pre>
<p>或者</p>
<pre><code class="language-shell"> $CATALINA_HOME/bin/startup.sh
# 开启
$CATALINA_HOME/bin/shutdown.sh
# 关闭
</code></pre>
<h4 id="三查看">三、查看</h4>
<p>** 打开浏览器输入<code>localhost:8080</code> **</p>
<pre><code class="language-html">It works !
If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!
This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat8/webapps/ROOT/index.html
Tomcat8 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat8 and CATALINA_BASE in /var/lib/tomcat8, following the rules from /usr/share/doc/tomcat8-common/RUNNING.txt.gz.
You might consider installing the following packages, if you haven't already done so:
tomcat8-docs: This package installs a web application that allows to browse the Tomcat 8 documentation locally. Once installed, you can access it by clicking here.
tomcat8-examples: This package installs a web application that allows to access the Tomcat 8 Servlet and JSP examples. Once installed, you can access it by clicking here.
tomcat8-admin: This package installs two web applications that can help managing this Tomcat instance. Once installed, you can access the manager webapp and the host-manager webapp.
NOTE: For security reasons, using the manager webapp is restricted to users with role "manager-gui". The host-manager webapp is restricted to users with role "admin-gui". Users are defined in /etc/tomcat8/tomcat-users.xml.
</code></pre>
<p><strong>成功</strong></p>
<h4 id="四配置环境变量">四、配置环境变量</h4>
<ol start="0">
<li>在/etc/environment文件中写入JAVA_HOME="JDK主目录的绝对路径"</li>
</ol>
<blockquote>
<p>设置 java环境变量</p>
</blockquote>
<ol>
<li>编辑profile (全局)配置文件<pre><code class="language-shell">sudo vim /etc/profile
</code></pre>
</li>
<li>添加 CATALINA_HOME和 CATALINA_BASE 到文件末尾<pre><code class="language-shell"># tomcat 全局变量
CATALINA_HOME=/usr/share/tomcat8
CATALINA_BASE=/var/lib/tomcat8
</code></pre>
</li>
<li>运行 profile 文件<pre><code class="language-shell"> source /etc/profile
</code></pre>
</li>
<li>输出 CATALINA_HOME 和 CATALINA_BASE 测试<pre><code class="language-shell">yang@yang:~$ echo $CATALINA_HOME
</code></pre>
</li>
</ol>
<p>/usr/share/tomcat8<br>
yang@yang:~$ echo $CATALINA_BASE<br>
/var/lib/tomcat8<br>
```</p>
<h4 id="四文件">四、文件</h4>
<ul>
<li>/var/lib/tomcat8/webapps/ROOT/index.html 项目位置</li>
<li>/etc/tomcat8/tomcat-users.xml 用户权限设置</li>
<li>/usr/share/doc/tomcat8-common/RUNNING.txt 说明文件</li>
</ul>
<h4 id="五项目结构">五、项目结构</h4>
<ol>
<li><code>/var/lib/tomcat8 </code> -><code>CATALINA_BASE</code></li>
</ol>
<pre><code class="language-shell"> yang@yang:/var/lib/tomcat8$ pwd
/var/lib/tomcat8
yang@yang:/var/lib/tomcat8$ ls -al
总用量 20
drwxr-xr-x5 root root 4096 7月15 20:22 .
drwxrwxrwx 70 root root 4096 7月15 18:53 ..
lrwxrwxrwx1 root root 12 8月252018 conf -> /etc/tomcat8 # 配置文件
drwxr-xr-x2 tomcat8 tomcat8 4096 8月252018 lib # 依赖 jar 包
lrwxrwxrwx1 root root 17 8月252018 logs -> ../../log/tomcat8 # 日志
drwxr-xr-x2 root root 4096 7月15 20:22 policy # 政策
drwxrwxr-x3 tomcat8 tomcat8 4096 7月15 18:53 webapps # 存放发布的项目
lrwxrwxrwx1 root root 19 8月252018 work -> ../../cache/tomcat8 # 运行时 产生的文件
yang@yang:/var/lib/tomcat8$
</code></pre>
<ol start="2">
<li><code>/usr/share/tomcat8</code> -> <code>CATALINA_HOME</code></li>
</ol>
<pre><code class="language-shell"> yang@yang:/usr/share/tomcat8$ pwd
/usr/share/tomcat8
yang@yang:/usr/share/tomcat8$ ls -al
总用量 48
drwxrwxrwx 6 root root4096 7月15 20:04 .
drwxrwxrwx 281 root root 12288 7月15 19:03 ..
drwxrwxrwx 2 root root4096 7月15 18:51 bin #启动和关闭的sh脚本
-rw-r--r-- 1 root root 39 8月252018 defaults.md5sum
-rw-r--r-- 1 root root1911 8月252018 defaults.template
drwxr-xr-x 2 root root4096 7月15 18:51 lib # 库
-rw-r--r-- 1 root root 53 8月252018 logrotate.md5sum
-rw-r--r-- 1 root root 134 8月252018 logrotate.template
drwxr-xr-x 2 yang yang4096 7月15 20:04 logs # 自己创建的没用
drwxr-xr-x 4 root root4096 7月15 18:53 skel
</code></pre>
<ol start="3">
<li>/etc/tomcat8</li>
</ol>
<pre><code class="language-shell"> yang@yang:/etc/tomcat8$ pwd
/etc/tomcat8
yang@yang:/etc/tomcat8$ ls -al
总用量 224
drwxr-xr-x 4 root root 4096 7月15 18:53 .
drwxr-xr-x 140 root root 12288 7月15 20:24 ..
drwxrwxr-x 3 root tomcat8 4096 7月15 18:51 Catalina
-rw-r----- 1 root tomcat8 7770 8月252018 catalina.properties
-rw-r----- 1 root tomcat8 1338 7月 52016 context.xml # 所有 web 项目的配置信息
-rw-r----- 1 root tomcat8 1149 7月 52016 jaspic-providers.xml
-rw-r----- 1 root tomcat8 2686 8月252018 logging.properties
drwxr-xr-x 2 root tomcat8 4096 7月15 19:03 policy.d
-rw-r----- 1 root tomcat8 7528 8月252018 server.xml # 服务器配置文件
-rw-r----- 1 root tomcat8 2164 7月 52016 tomcat-users.xml # 用户配置文件
-rw-r----- 1 root tomcat8 168133 8月312016 web.xml
yang@yang:/etc/tomcat8$
</code></pre><br><br>
来源:https://www.cnblogs.com/javayanglei/p/13308389.html
頁:
[1]