apache Tomcat 安装目录在ubuntu / eclipse + ubuntu 配置Tomcat
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11219678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
apache Tomcat installation directory in ubuntu / configure Tomcat in eclipse + ubuntu
提问by Jisson
I installed java7 and ApacheTomcat7 in my Ubuntu12.04, and download eclipse EE. And now I have to configure my eclipse with tomcat. For I want to find the tomcat installation directory. How can I find it. I installed java and tomcat using Ubuntu software centre.
我在我的Ubuntu12.04中安装了java7和ApacheTomcat7,并下载了eclipse EE。现在我必须用 tomcat 配置我的 eclipse。因为我想找到tomcat的安装目录。我怎样才能找到它。我使用 Ubuntu 软件中心安装了 java 和 tomcat。
回答by Chandra Sekhar
1.Download the package "apache-tomcat-7.0.6.tar.gz
" from the below link
http://tomcat.apache.org/download-70.cgi[tar.gz]
1.apache-tomcat-7.0.6.tar.gz
从以下链接下载包“ ”
http://tomcat.apache.org/download-70.cgi[tar.gz]
2.Now unpack it with the following command:
2.现在使用以下命令解压:
tar xvzf apache-tomcat-7.0.8.tar.gz
3.Then move to more appropriate directory, in our case in /usr/share/tomcat7
, but can be in any directory. We do this with the command:
3.然后移动到更合适的目录,在我们的例子中/usr/share/tomcat7
,但可以在任何目录中。我们使用以下命令执行此操作:
sudo mv apache-tomcat-7.0.8/ /usr/share/tomcat7
4.Now define the environment variables JAVA_HOME
and JRE_HOME
. This file is in the "environment" in / etc. Command to edit the file:
4.现在定义环境变量JAVA_HOME
和JRE_HOME
. 该文件在 /etc 中的“环境”中。编辑该文件的命令:
sudo gedit /etc/environment
5.Here we record the routes where we have installed Java in my case this is as follows:
5.这里我们记录下我安装Java的路径如下:
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
PATH="...(other path):$JAVA_HOME:$JRE_HOME"
6. IMPORTANT:Verify the routes where they have installed Java.
6. 重要:验证安装了 Java 的路由。
sometimes tomcat does not recognize, but a surefire way of recognizing that tomcat is to define the file paths inside "catalina.sh
" located in tomcat7/bin
. To modify this file use the command:
有时 tomcat 无法识别,但识别 tomcat 的可靠方法是在catalina.sh
位于tomcat7/bin
. 要修改此文件,请使用以下命令:
sudo gedit /usr/share/tomcat7/bin/catalina.sh
Now insert the JAVA_HOME
and JRE_HOME
after the first line, so the file is as follows:
现在在第一行后面插入JAVA_HOME
和JRE_HOME
,所以文件如下:
#!/bin/sh
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
# Licensed to the Apache Software Foundation (ASF)...
#...
#...
....
Now configure Tomcat users, this is done in the file "tomcat-users.xml
" directory tomcat7/conf
. Command to edit the file:
现在配置Tomcat用户,这是在文件“ tomcat-users.xml
”目录中完成的tomcat7/conf
。编辑文件的命令:
sudo gedit /usr/share/tomcat7/conf/tomcat-users.xml
7.Unlike previous versions, the administrator should own role "manager" now it should be "manager-gui
"to operate on the web administration tomcat7. The file would be as follows:
7.不同于以前的版本,管理员应该拥有“manager”这个角色,现在它应该是“ manager-gui
”来操作tomcat7的web管理。该文件如下:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="admin"/>
<user username="usuario" password="contrasena" roles="manager-gui,admin-gui,manager,admin,manager-script,admin-script"/>
</tomcat-users>
8.For further info look here
set-up-eclipse-and-tomcat-7-on-ubuntu-12-04
cannot-create-a-server-using-the-selected-type-eclipse-tomcat
8.有关更多信息,请查看此处
set-up-eclipse-and-tomcat-7-on-ubuntu-12-04
cannot-create-a-server-using-the-selected-type-eclipse-tomcat
回答by Dmitriy Sukharev
Actually you can use Tomcat from Ubuntu repository with Eclipse (at least with Kepler version). It just requires couple of additional steps.
实际上,您可以将 Ubuntu 存储库中的 Tomcat 与 Eclipse 一起使用(至少使用 Kepler 版本)。它只需要几个额外的步骤。
- Open Eclipse. Press File ? New ? Other... ? Servers ? Server ? Next > ? Apache ? Tomcat v7.0 Server
- Select Tomcat Installation Directory: /usr/share/tomcat7
- Click Finish, ignore error message, click Finish again
Copy Tomcat configuration to workspace executing from terminal:
sudo cp -r /etc/tomcat7/* ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ sudo chown -R $USER:$USER ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/
Concat policy files into one file:
cd ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ cat policy.d/* > catalina.policy
Either shutdown tomcat7 service every time before running it from Eclipse, or edit tomcat's ports in config files of your workspace (I suggest editing configs):
gedit ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/server.xml
You are interested in changing ports 8080, 8009 and 8005 (to, say, 9090, 9009 and 9005).
- Return to Eclipse, select 'Servers' in Project Explorer (left panel), press F5, to refresh it.
- Start Tomcat from Eclipse (see Servers tab in the bottom panel of Eclipse).
- 打开日食。按文件 ? 新的 ?其他... ?服务器?服务器 ?下一个 > ? 阿帕奇?Tomcat v7.0 服务器
- 选择Tomcat安装目录:/usr/share/tomcat7
- 点击完成,忽略错误信息,再次点击完成
将 Tomcat 配置复制到从终端执行的工作区:
sudo cp -r /etc/tomcat7/* ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ sudo chown -R $USER:$USER ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/
将策略文件合并为一个文件:
cd ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ cat policy.d/* > catalina.policy
每次在从 Eclipse 运行之前关闭 tomcat7 服务,或者在工作区的配置文件中编辑 tomcat 的端口(我建议编辑配置):
gedit ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/server.xml
您有兴趣更改端口 8080、8009 和 8005(例如,更改为 9090、9009 和 9005)。
- 返回 Eclipse,在 Project Explorer(左侧面板)中选择“Servers”,按 F5,刷新它。
- 从 Eclipse 启动 Tomcat(请参阅 Eclipse 底部面板中的服务器选项卡)。
I wrote this answer based on my article. It's a bit more detailed, so refer to it if necessary.
我根据我的文章写了这个答案。比较详细,有需要的可以参考一下。
回答by Karthik Arun
You can install tomcat from repository.
您可以从存储库安装 tomcat。
search for tomcat.
sudo apt-cache search tomcat
Install tomcat admin and tomcat
sudo apt-get install tomcat7-admin sudo apt-get install tomcat7
Check for tomcat status
sudo service tomcat7 status
Start and stop tomcat
sudo service tomcat7 start sudo service tomcat7 stop
搜索 tomcat。
sudo apt-cache search tomcat
安装 tomcat admin 和 tomcat
sudo apt-get install tomcat7-admin sudo apt-get install tomcat7
检查 tomcat 状态
sudo service tomcat7 status
启动和停止tomcat
sudo service tomcat7 start sudo service tomcat7 stop
Bin folder for tomcat7 is at /usr/share/tomcat7 and logs and config are are at /usr/lib/tomcat7
tomcat7 的 bin 文件夹位于 /usr/share/tomcat7,日志和配置位于 /usr/lib/tomcat7
Source: http://www.allaboutjava.club/linux/linux-install-tomcat7-on-ubuntu
来源:http: //www.allaboutjava.club/linux/linux-install-tomcat7-on-ubuntu
回答by user3745997
I like to use packages from the repository every time possible.
我喜欢每次都使用存储库中的包。
In this case:
在这种情况下:
sudo apt-get install tomcat7-user
sudo tomcat7-instance-create /srv/tomcats/ubuntu
sudo ln -s /usr/share/tomcat7/lib /srv/tomcats/ubuntu/
For tomcat6 the ln step can be skipped.
对于 tomcat6,可以跳过 ln 步骤。
Then just use this path to add a tomcat7 server on eclipse. Tested on 14.04 and eclipse kepler sr2. Should work on 12.04.
然后就用这个路径在eclipse上添加一个tomcat7服务器即可。在 14.04 和 eclipse kepler sr2 上测试。应该在 12.04 上工作。
回答by user2640830
Don't use by default command, like sudo apt-get install tomcat7
.
不要使用默认命令,例如sudo apt-get install tomcat7
.
If you follow the above command then you will face lots of problem because CATALINA_HOME
and CATALINA_BASE
will be in different locations. In that case you have to declare environment variable separately.
如果你按照上面的命令,那么你将面临很多的问题,因为CATALINA_HOME
并CATALINA_BASE
会在不同的位置。在这种情况下,您必须单独声明环境变量。