Initial Tomcat configuration in Ubuntu
Tomcat initial configuration in Ubuntu 1. Download the tomcat installation package
Download the installation package from the official tomcat website http://tomcat.apache.org, and then extract it to a directory, such :~ /Opt/apache-tomcat-7.0.63
We recommend that you do not use the installation packages that have been installed in each Linux release, because the installation packages in each release install tomcat in different locations. Therefore, we recommend that you do not use tomcat in the source.
$ Tar xzvf apache-tomcat-7.0.63.tar.gz-C ~ /Opt
2. Listen to port 80
Modify server. xml in the conf directory under the tomcat installation directory
$ Cd ~ /Opt/apache-tomcat-7.0.63/conf
$ Vim server. xml
...
<Connector port = "80"...>
...
3. Add users
Modify the tomcat-users.xml file under the conf directory under the Tomcat 7 installation directory
$ Cd ~ /Opt/apache-tomcat-7.0.63/conf
$ Vim tomcat-user.xml.
...
<Role rolename = "admin-gui"/>
<Role rolename = "manager-gui"/>
<User username = "admin" password = "1234" roles = "admin-gui"/>
<User username = "manager" password = "1234" roles = "manager-gui"/>
...
4. Set the working directory
The default directory of web programs under Tomcat is $ TOMCAT_INSTALL_DIR/webapps. You only need to place your web program directory in this directory, but you usually need to set your own working directory. Two methods:
1) Use the docBase variable in Context to set
$ Vim $ TOMCAT_INSTALL_DIR/conf/Catalina/localhost/mywebapp. xml
<Context path = "/mywebapp" docBase = "~ /Working/project/program/webapps/mywebapp "reloadable =" true "/>
Note: For Versions later than tomcat 5.5, you do not need to set the path variable. tomcat determines the path based on the file name. For example, if the file name is mywebapp. xml, the path is/mywebapp.
2) Soft link
$ Cd $ TOMCAT_INSTALL_DIR/webapps
$ Ln-s ~ /Working/project/program/webapps/mywebapp
5. install Tomcat as a service started with the System
1) set the JAVA_HOME environment variable in the $ TOMCAT_INSTALL_DIR/bin/setenv. sh script.
$ Vim $ TOMCAT_INSTALL_DIR/bin/setenv. sh
#! /Bin/sh
JAVA_HOME =/usr/lib/jvm/java-7-openjdk-i386
2) Copy $ TOMCAT_INSTALL_DIR/bin/catalina. sh to the/etc/init. d directory, add the LSB setting information at the beginning of the script, and set the tomcat installation environment variable:
$ Sudo cp catalina. sh/etc/init. d/tomcat
$ Sudo vim/etc/init. d/tomcat
### BEGIN INIT INFO
# Provides: apache-tomcat
# Required-Start: $ all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Run/etc/rc. local if it exist
### END INIT INFO
CATALINA_HOME = "/home/cb/opt/apache-tomcat-7.0.63"
Cd $ CATALINA_HOME/bin
3) install the service
$ Sudo update-rc.d-f tomcat ults
4) start/stop the service
$ Sudo service tomcat start
$ Sudo service tomcat stop
6. Test
$ Sudo service tomcat start
Then, open the browser and enter: http: // localhost
The above test passed in Ubuntu 14.04.
For more Tomcat tutorials, see the following:
Install and configure the Tomcat environment in CentOS 6.6
Install JDK + Tomcat in RedHat Linux 5.5 and deploy Java Projects
Tomcat authoritative guide (second edition) (Chinese/English hd pdf + bookmarks)
Tomcat Security Configuration and Performance Optimization
How to Use Xshell to view Tomcat real-time logs with Chinese garbled characters in Linux
Install JDK and Tomcat in CentOS 64-bit and set the Tomcat Startup Procedure
Install Tomcat in CentOS 6.5
Tomcat details: click here
Tomcat: click here
This article permanently updates the link address: