作者:欣欣2602916441 | 来源:互联网 | 2023-05-17 07:47
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 个解决方案
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一起使用的“正确”方法。