Installing and configuring Tomcat under Linux

Source: Internet
Author: User
Tags tomcat server



1. Install Tomcat1.1 Downloads Tomcat Downloads Tomcat from official website http://tomcat.apache.org/, saved in the/home directory (and can be a different directory, of course).
Note: In the Tomcat website, download the tar.gz under the binary distributions under core.
Download and copy it to your installation directory: CP Apache-tomcat-8.0.21.tar.gz/home
1.2 Installing the Tomcat Decompression Pack: TAR-ZXVF apache-tomcat-8.0.21.tar.gz
After decompression we found that the script in the bin directory has two formats,. bat and. Sh, which means that this is common under Windows and Linux, and different systems use different scripts.
2. Once the Tomcat Tomcat installation is complete, the next step is to manually turn on Tomcat or you won't be able to access it.
2.1 Directory Description
CD   /homecd  apache-tomcat-8.0.21//home/apache-tomcat-8.0.21# lsbin  lib   logs    release-notes  Temp     


    • conf LICENSE NOTICE RUNNING.txt WebApps
    • Bin: Holds executable scripts for starting and shutting Tomcat.
    • Conf:tomcat configuration files, such as Server.xml (Tomcat server configuration file) and Web. XML (shared by all WebApps profiles), the password forgot to look at tomcat-users.xml.
    • WebApps: Store Web applications, and applications that users themselves need to deploy are also placed in this directory.
    • Work:tomcat the temporary files generated by the runtime, including the class files generated after the JSP compilation.
    • Logs: The log file is stored.
    • TEMP:JVM the directory used to hold temporary files (java.io.tmpdir).
2.2tomcat operation/home/apache-tomcat-8.0.21/bin#./startup.sh//Start Tomcat
/home/apache-tomcat-8.0.21/bin#./shutdown.sh//Turn Tomcat off
/home/apache-tomcat-8.0.21/logs# tail-f catalina.out//view tomcat log (-F means that new logs will be printed continuously)
Tomcat console displayed under Linux
$TOMCAT _home for the TOMCAT installation directory. In Linux if you press $tomcat_home/bin/startup.sh to start Tomcat, you won't get console effects like windows. It's inconvenient to look at the logs. Isn't Linux under the same console as Windows, it's not, it's just that everyone is used to starting it. Under Linux, how do I make the boot tomcat look like Windows? , the solution is as follows:
/home/apache-tomcat-8.0.21/bin#./catalina.sh Run

CTRL + C: Can end log printing, but does not affect normal application operation.
TOP-C: Windows-like Task Manager.
Viewing the Java process: Ps-ef |grep java

3. Setting environment variables I think of this, someone might ask, why set the environment variable.

In general, running the Tomact command is able to find the Tomcat directory and know where he is installed.
The following sets a two environment variables catalina_home and Catalina_base,

Edit the ~/.BASHRC file. Join
Export catalina_base=/usr/local/apache-tomcat-8.0.21
Export catalina_home=/usr/local/apache-tomcat-8.0.21
Next, verify that the variable settings are in effect
Rebootecho  $CATALINA _home    /usr/local/apache-tomcat-8.0.21echo  $CATALINA _base    /usr/local/ apache-tomcat-8.0.21
shutting down the firewall:
Service Iptables Stop
Tomcat boot auto-load:
The bin directory in the Tomcat installation directory has two scripts to start and stop Tomcat, respectively, startup.sh,shutdown.sh, which you can use to manually start and stop the Tomcat service and perform the post-installation test. Our simplest approach is to start Tomcat with startup.sh, edit/etc/rc.d/rc.local Add content (assuming the JDK directory is/usr/jdk,tomcat directory is/apache/tomcat)
Export jdk_home=/usr/jdk<

4. Other operations4.1 The default setting for activating root root is no activation (disabled). To activate root, open the file
Tomcat/conf/server.xml
Then put
<!--
<context path= "" docbase= "ROOT" debug= "0"/>
-
Remove the <!--and-->
4.2 Activating the Invoker Servlet removes the comments from the following fields in the Tomcat/conf/web.xml
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
4.3 Set port tomcat By default port number is 8080. Since Tomcat is a standalone (Standalone) Web Server, it can work independently without Apache, so you can not install Apache so you can set tomcat on port 80. This allows you to omit: 8080 in the URL. Open the file Tomcat/conf/server.xml and locate the following fields:
<connector
Classname= "Org.apache.coyote.tomcat4.CoyoteConnector" port= "8080" ...

/>
Then change the 8080 to 80.


4.4 Create a temp subdirectory under the/opt/tomcat/directory, create a temp subdirectory mkdir temp, and then use the browser to open the following Web page http://localhost/or http://localhost:8080/ (If the port number is not changed to 80) if you see the Tomcat Web page (index.jsp), it proves that the Tomcat installation was successful and has been started.
4.5 Register your own project assuming you have a JSP project of your own, he should be installed in the following directory:
/opt/tomcat/webapps/myproject
You have to add a line to the tomcat/conf/server.xml.
<context
Path= "/myproject" docbase= "MyProject"
debug= "0"/>
The corresponding address in the browser is:
Http://localhost/myproject

5. Utility Command Reference ① view the currently running process: PS-EF | grep java
② Terminate process: kill-9 [PID]//9 indicates that the forced process stops immediately, usually using PS to view the process PID, terminate the process with the KILL command
③ View Network port usage: NETSTAT-TUPLN or NETSTAT-PLN
④ Modify localhost:vi/etc/hosts//Sometimes IP can be accessed, localhost cannot access it because of this problem.
⑥ Start-up autorun: Open applications, system settings, server settings, Services-〉 actions, add service input Catalina click OK.
⑦tomcat Add User: In Ubuntu, Tomcat is no user by default,/conf/tomcat-users.xml find </tomcat-users> this line, add:
<role rolename= "admin"/>
<role rolename= "Manager"/>
<user username= "admin" password= "admin" roles= "admin"/>
<user username= "Both" password= "both" roles= "Admin,manager"/>
<user username= "Manager" password= "manager" roles= "manager"/>
⑧ See how many bits of Linux are: File/sbin/init

Reference: http://blog.csdn.net/zhuying_linux/article/details/6583096/


20150422


Tool Use series

--------------------------------------------

Contact Information

--------------------------------------------

Weibo:aresxiong

e- mail: [email protected]

------------------------------------------------

Installing and configuring Tomcat under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.