热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

不能将任何东西放入/var/lib/tomcat7/webapps/?-Cannotputanythinginto/var/lib/tomcat7/webapps/

IwasstartingonJAVAwebdevelopmenttodayandencounteredsomeproblems,Iinstalledmytomcat7o

I was starting on JAVA web development today and encountered some problems, I installed my tomcat7 on my ubuntu machine. Now when I browse to //localhost:8080, I get the default welcome page saying:

我今天从JAVA web开发开始,遇到了一些问题,我在我的ubuntu机器上安装了tomcat7。现在,当我浏览到//localhost:8080时,我得到默认的欢迎页面:

This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat7/webapps/ROOT/index.html

这是默认的Tomcat主页。它可以在本地文件系统上找到:/var/lib/tomcat7/webapps/ROOT/index.html。

Tomcat7 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7, following the rules from /usr/share/doc/tomcat7-common/RUNNING.txt.gz.

Tomcat7的退役人员可能会很高兴地得知,这一系统实例是在/usr/share/tomcat7和CATALINA_BASE中与CATALINA_HOME一起安装的,这是在/usr/share/doc/tomcat7-common/RUNNING.txt.gz的规则下完成的。

But strangely when I try echo $CATALINA_HOME nothing shows up. Also I can not copy/create anything in the default /var/lib/tomcat7/ROOT though it's just a matter of providing few permissions but I was wondering whether it is the right way to do it?,

但奇怪的是,当我尝试echo $CATALINA_HOME时,什么也没有出现。另外,我不能复制/创建默认的/var/lib/tomcat7/ root中的任何东西,尽管这只是提供一些权限的问题,但是我想知道这是否是正确的方法?

What I would like to do is create a separate directory in my home where I can put my web application and tomcat can read hem from there. Is there a way to do it? In apache I can do it by changing the document-root and directory but I don't know how to do it for tomcat

我想做的是在我的家里创建一个单独的目录,我可以将我的web应用程序和tomcat从那里读取。有办法吗?在apache中,我可以通过更改文档根目录和目录来实现它,但是我不知道如何为tomcat执行它。

3 个解决方案

#1


10  

But strangely when I try echo $CATALINA_HOME nothing shows up.

但奇怪的是,当我尝试echo $CATALINA_HOME时,什么也没有出现。

This is because the packaged version sets CATALINA_HOME just prior to launching Tomcat, after reading it from a configuration file (typically somewhere in /etc).

这是因为在从一个配置文件(通常是在/etc)中读取它之前,打包的版本在启动Tomcat之前设置了CATALINA_HOME。

Also I can not copy/create anything in the default /var/lib/tomcat7/ROOT though it's just a matter of providing few permissions but I was wondering whether it is the right way to do it?

另外,我不能复制/创建默认的/var/lib/tomcat7/ root中的任何东西,尽管这只是提供一些权限的问题,但是我想知道这是否是正确的方法?

The permissions problem has to do with you not being root (or the Tomcat user). Most packaged Tomcat installations (deb or RPM) tend to install with a specific user in mind, and copying stuff in as a different sometimes won't work.

权限问题与您不作为根(或Tomcat用户)有关。大多数打包的Tomcat安装(deb或RPM)都倾向于将特定的用户放在脑海中,而将其复制到不同的地方有时是行不通的。

/usr/share/tomcat7 is your CATALINA_HOME directory, and it has links to the other directories, such as /var/lib/tomcat7/webapps, /etc/tomcat7, etc. You shouldn't copy directly into a web application, you should package the web application into a WAR file and "deploy" it. The advantages are numerous.

/usr/share/tomcat7是您的CATALINA_HOME目录,它与其他目录有链接,比如/var/lib/tomcat7/webapps、/etc/tomcat7等。您不应该直接复制到web应用程序中,您应该将web应用程序打包到WAR文件中并“部署”它。有很多的优势。

What I would like to do is create a separate directory in my home where I can put my web application and tomcat can read hem from there. Is there a way to do it?

我想做的是在我的家里创建一个单独的目录,我可以将我的web应用程序和tomcat从那里读取。有办法吗?

Yes, one is created when "deploying a web app". Look to the standard Tomcat7 documentation, and consider installing the "manager" web application if you like a non-command line interface. Now that you know what "installation" of a web app is called, it will likely be an easier task.

是的,一个是在“部署一个web应用程序”时创建的。看看标准的Tomcat7文档,如果您喜欢一个非命令行界面,可以考虑安装“manager”web应用程序。既然您已经知道了web应用程序的“安装”,那么它可能是一项更简单的任务。

In apache I can do it by changing the document-root and directory but I don't know how to do it for tomcat

在apache中,我可以通过更改文档根目录和目录来实现它,但是我不知道如何为tomcat执行它。

Tomcat has a different, slightly more restrictive set of requirements for a document-root. You need to learn it, and just come to terms with the idea that it's never going to be the same. Basically under the "webapps" directory, is a WAR file or a expanded directory that came from a WAR file. Editing in-place is not a good idea for Tomcat, as the CGI-equivalents are not read from disk each time they are ran, they are linked into the memory of Tomcat. This means that a change in the directory might not affect your web application, which is good enough reason to not bother changing the on-disk files for a deployed web application.

Tomcat对文档根有一个不同的、略微更严格的需求集。你需要学习它,并且接受它永远不会是一样的观点。基本上在“webapps”目录下,是WAR文件,或者是来自WAR文件的扩展目录。对Tomcat来说,对其进行编辑不是一个好主意,因为它们每次运行时都不会从磁盘上读取,它们会链接到Tomcat的内存中。这意味着目录中的更改可能不会影响您的web应用程序,这足以使您不必为已部署的web应用程序更改磁盘上的文件。

Modify the web application, repackage it, and update the deployment. It's really the "right" way to go with Tomcat.

修改web应用程序,重新打包它,并更新部署。这是与Tomcat一起使用的“正确”方法。

#2


5  

Give permission 777 to the webroot folder

向webroot文件夹授予权限777。

sudo chmod -R 777 Webroot

After moving to the tomcat folder

移动到tomcat文件夹后。

#3


0  

But strangely when I try echo $CATALINA_HOME nothing shows up.

但奇怪的是,当我尝试echo $CATALINA_HOME时,什么也没有出现。

If you installed tomcat7 by using this command

如果您使用此命令安装tomcat7。

sudo apt-get install tomcat7

/usr/share/tomcat7 is your CATALINA_HOME though, you need to add this as an environment variable in the /.bashrc file.

/usr/share/tomcat7是您的CATALINA_HOME,您需要将其添加为/中环境变量。bashrc文件。(

sudo vi ~/.bashrc

You can add this information to the end of the file:

您可以将此信息添加到文件的末尾:

export JAVA_HOME=/usr/lib/jvm/default-java
export CATALINA_HOME=/usr/share/tomcat7

Save and exit out of .bashrc. You can make the changes effective by restarting the bashrc file.

保存并退出.bashrc。您可以通过重新启动bashrc文件使更改生效。

. ~/.bashrc

Now, you would see the path when echo $CATALINA_HOME.

现在,你会看到echo $CATALINA_HOME的路径。

Reference

参考


推荐阅读
  • 本文详细介绍了如何准备和安装 Eclipse 开发环境及其相关插件,包括 JDK、Tomcat、Struts 等组件的安装步骤及配置方法。 ... [详细]
  • 深入解析 Apache Shiro 安全框架架构
    本文详细介绍了 Apache Shiro,一个强大且灵活的开源安全框架。Shiro 专注于简化身份验证、授权、会话管理和加密等复杂的安全操作,使开发者能够更轻松地保护应用程序。其核心目标是提供易于使用和理解的API,同时确保高度的安全性和灵活性。 ... [详细]
  • Docker的安全基准
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 深入理解Cookie与Session会话管理
    本文详细介绍了如何通过HTTP响应和请求处理浏览器的Cookie信息,以及如何创建、设置和管理Cookie。同时探讨了会话跟踪技术中的Session机制,解释其原理及应用场景。 ... [详细]
  • 本文详细介绍了Java中org.w3c.dom.Text类的splitText()方法,通过多个代码示例展示了其实际应用。该方法用于将文本节点在指定位置拆分为两个节点,并保持在文档树中。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • 本文详细介绍了 Java 中 org.apache.xmlbeans.SchemaType 类的 getBaseEnumType() 方法,提供了多个代码示例,并解释了其在不同场景下的使用方法。 ... [详细]
  • 本文详细介绍如何利用已搭建的LAMP(Linux、Apache、MySQL、PHP)环境,快速创建一个基于WordPress的内容管理系统(CMS)。WordPress是一款流行的开源博客平台,适用于个人或小型团队使用。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 在当前众多持久层框架中,MyBatis(前身为iBatis)凭借其轻量级、易用性和对SQL的直接支持,成为许多开发者的首选。本文将详细探讨MyBatis的核心概念、设计理念及其优势。 ... [详细]
  • 本文介绍如何使用 NSTimer 实现倒计时功能,详细讲解了初始化方法、参数配置以及具体实现步骤。通过示例代码展示如何创建和管理定时器,确保在指定时间间隔内执行特定任务。 ... [详细]
author-avatar
欣欣2602916441
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有