且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法找到的httpd.conf

更新时间:2022-12-08 10:29:43

由于@Woody说,Tomcat不使用的httpd.conf文件:这是一个Apache httpd的事情(httpd的是Web服务器,Tomcat是一个Java应用服务器)

您没有提到您正在使用或什么包管理软件,你使用的是什么操作系统(如百胜,易等),所以我给你,如果你已经下载并直接来自Apache Tomcat安装的一般信息。组织(我通常建议人们为一些做的原因)。

Tomcat的保持在Tomcat的基本安装目录(通常被称为$ CATALINA_BASE为了方便)的的conf / server.xml中文件其服务器范围内的配置:在这里,您可以配置东西像什么类型的连接器(如HTTP,HTTPS,AJP等)使用,哪些端口他们应该听,集群配置,会话持久性,全局JNDI和领域的资源。也有的conf / web.xml文件 conf / context.xml文件定义默认值部署在所有的webapps文件Tomcat的实例,但***不要动这些文件,除非你有一个很好的理由对其进行修改。

当你想要部署web应用程序(在默认配置),所有你需要做的就是放下.war文件到 $ CATALINA_BASE / webapps /目录目录web应用程序将被部署到该文件减去.WAR后缀的名称匹配的上下文路径(又名URL preFIX)。所以,如果你有一个名为mygreatwebapp.war一个WAR文件,那么它将被部署,这样你的客户可以在 HTTP实现它:// yourhost / mygreatwebapp / 。还有你可以给一个WAR文件,以便它有一个空的上下文路径一个特殊的名字:如果您命名WAR文件 ROOT.war (案例事项),那么你的web应用可以在 HTTP达成:// yourhost / 。 (如果你愿意使用爆炸-WAR目录,而不是WAR文件,上面的一切都仍然适用,除了目录根本就没有.war扩展名)。

由于你原来的问题,这听起来像所有你想要做的是拖放ROOT.war文件到 $ CATALINA_BASE / webapps中(或更换一个已经存在):这将部署你想成你可以称之为默认Web根目录的URL空间什么的webapp 。

更新
如果您想要更改所有的webapps住了主机的目录,你可以修改 $ CATALINA_BASE / conf目录/ server.xml中并修改&LT ;主机> 的appBase 属性指向,比如说, / cfusion /主/ WWW / 。这将部署在所有 / cfusion /主/ WWW / 作为独立的web应用。

的WAR文件和目录

如果你只是想从任意地点为一个单一的Web应用程序,您可以创建在 $ CATALINA_BASE / conf目录/ [引擎] / [主机名] / [APPNAME]的.xml 部署的文件code>。这就像一个标准的文件 META-INF / context.xml中,并包含一个<语境> 元素,除非你必须指定一个的docBase 指向你的webapp(如 / cfusion /主/ WWW / mywebapp )

I'm running tomcat and I want to change the default webroot so that it points to another location. Is there a way to find out what's running tomcat or where the default webroot is set as I can't find httpd.conf which is where I believe it's usually set?

Cheers,

Alexei Blue.

**UPDATE:**

It's been a long time since I looked at this question that I forgot about it. In the end it turned out that we were using Apache HTTPD to accept requests from port 80. From there we had the webroot and ProxyPass rules set in the /etc/httpd/conf/virtual-hosts/default.conf file (these can also be set in /etc/httpd/conf/httpd.conf). From there we had several tomcat instances running, all hosted on different ports which are setup in apache-tomcat-x/conf/server.xml.

When I wrote this question I was trying to setup a new tomcat instance to run an application in development and was told I would need to change the webroot to access my application, which was incorrect. Instead what I needed was to include a ProxyPass rule so that when my application name was recognised in the URL, HTTPD would send the request to the correct tomcat instance to be processed. E.g.

www.domain.com/myApplication

In /etc/httpd/conf/virtual-hosts/default.conf

ProxyPass /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/
ProxyPassReverse /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/

Where the ajp_port is setup in apache-tomcat-x/conf/server.xml. I needed to ensure that non of the ports conflicted with other tomcat instances so remember to check all ports i.e. Shutdown, HTTP, HTTP with SSL, AJP etc.

As @Woody says, Tomcat does not use httpd.conf files: that's an Apache httpd thing (httpd is a web server, Tomcat is a Java application server).

You didn't mention what OS you are using or what package management software you are using (e.g. yum, apt, etc.) so I'll give you generic information as if you had downloaded and installed Tomcat directly from apache.org (which I usually recommend people do for a number of reasons).

Tomcat keeps its server-wide configuration in the conf/server.xml file in the Tomcat base installation directory (often called $CATALINA_BASE for convenience): here, you configure things like what types of connectors (e.g. HTTP, HTTPS, AJP, etc.) to use and which ports they should listen to, clustering configuration, session persistence, global JNDI and realm resources. There are also conf/web.xml and conf/context.xml files that define defaults for all webapps deployed on that instance of Tomcat, but it's best to leave those files alone unless you have a really good reason to modify them.

When you want to deploy a webapp (under the default configuration), all you need to do is drop a .WAR file into the $CATALINA_BASE/webapps/ directory and the webapp will be deployed into a "context path" (aka URL prefix) that matches the name of the file minus the ".WAR" suffix. So, if you have a WAR file called mygreatwebapp.war, then it will be deployed such that your clients can reach it at http://yourhost/mygreatwebapp/. There is a special name you can give a WAR file so that it has an empty context path: if you name your WAR file ROOT.war (case matters), then your webapp can be reached at http://yourhost/. (If you would rather use exploded-WAR directories instead of WAR files, everything above still applies except the directories simply don't have the .war extension).

Given your original question, it sounds like all you want to do is drop a ROOT.war file into $CATALINA_BASE/webapps (or replace the one that is already there): this will deploy whatever webapp you want into the URL space that you might call the "default webroot".

Update If you want to change the directory where all the webapps live for a host, you can modify $CATALINA_BASE/conf/server.xml and change the <Host>'s appBase attribute to point to, say, /cfusion/main/www/. That will deploy all the WAR files and directories in /cfusion/main/www/ as separate webapps.

If you just want to serve a single webapp from an arbitrary location, you may create a deployment file under $CATALINA_BASE/conf/[EngineName]/[HostName]/[appname].xml. This is a standard file like META-INF/context.xml and contains a <Context> element except that you will have to specify a docBase which points to your webapp (e.g. /cfusion/main/www/mywebapp).