Tomcat configuration in Linux

Source: Internet
Author: User
In Linux, Tomcat configuration-Linux Enterprise Application-Linux server application information. For details, refer to the following section. 1. Required software packages

J2sdk-1_4_1_02-linux-i586.bin (jdk1.4.1)
Apache2.0.40 (Red Hat Linux8.0)
Jakarta-tomcat-4.1.24.tar.gz (tomcat4.1.24)
Jakarta-tomcat-connectors-4.1.24-src.tar.gz (connectors4.1.24)

2. Install the required software

(1) first copy three files except apache to the/usr/local directory.
/J2sdk-1_4_1_02-linux-i586.bin
# Decompress jdk to the local directory to generate the corresponding directory

(2) tar zxpf jakarta-tomcat-4.1.24.tar.gz
# Decompress tomcat to the local directory to generate the corresponding directory

(3) tar zxpf jakarta-tomcat-connectors-4.1.24-src.tar.gz
# Remove ors ORS to the local directory to generate the corresponding directory

3. Set Environment Variables

Vi/etc/profile # edit/etc/profile

Add at the end of the file: # Note that for jakarta-tomcat, the jdk should set the directory corresponding to the cost machine, depending on the version.

PATH = "$ PATH:/usr/local/jakarta-tomcat/bin:/usr/local/jdk/jre/bin"

JAVA_HOME =/usr/local/jdk
Export JAVA_HOME

JRE_HOME =/usr/local/jdk/jre
Export JRE_HOME

TOMCAT_HOME =/usr/local/jakarta-tomcat
Export TOMCAT_HOME

CLASSPATH =/usr/local/jdk/lib:/usr/local/jdk/jre/lib
Export CLASSPATH

4. compile and generate mod_webapp.so

Cd/usr/local/jakarta-tomcat-connectors-4.1.24-src/webapp
# Enter the specified directory

./Support/buildconf. sh
# Generate the compilation configuration file

./Configure -- with-apxs
# Generate Makefile compilation files

(Note: If you are prompted that you cannot find apxs at this time, it indicates that your Apache installation has not installed the Apache additional development kit. Please download and install this development kit to solve this problem, this package is in the third part of the RedHat8 mounting disk, with the file name: httpd-devel-2.0.40-8.i386.rpm)

Make
# Compile and generate mod_webapp.so. The generated mod_webapp.so file is in the apache-2.0 directory.

Copy the mod_webapp.so file in the apache-2.0 directory to the/usr/lib/httpd/modules directory.
Check the attributes of the file/usr/lib/httpd/modules/mod_webapp.so. They should be consistent with those of other Modules files. If they are different, use chmod chgrp chown to modify them.

5. Test the Independent Environment

(1) to test the Java running status, run the following command:
Java-version
Javac-version
If you see the version number, JDK is successfully installed.

(2) to test the running status of Apache, run the following command:
/Etc/rc. d/init. d/httpd restart # restart Apache Server
In any browser, enter the server address and press Enter. The default Apache homepage is displayed.

(3) run the following command to test the running status of Jakarta-Tomcat:
Go to the bin directory under the tomcat installation directory
./Startup. sh # Start the jakarta-tomcat-4.1.24 Service
Enter the server address and port number 8080 in any browser and press enter to see the default homepage of the jakarta-tomcat-4.1.24
Example: http: // localhost: 8080
./Shutdown. sh # Shut down the jakarta-tomcat-4.1.24 Service

6. Integrated Installation settings

(1) modify the/etc/httpd/conf/httpd. conf file
After # Dynamic Shared Object (DSO) Support, add the following content:
LoadModule webapp_module modules/mod_webapp.so

(2) Test the configuration and Modules and run the following command:
Apachectl configtest
If Syntax OK appears, the Module is successfully installed and configured.

(3) modify the/etc/httpd/conf/httpd. conf file
Add the following content at the end of the file:
WebAppConnection warpConnection warp localhost: 8008
WebAppDeploy examples warpConnection/examples/

Specify the connection between tomcat and apache through port 8008. Specify the application to be deployed in line 4. The two commands are in the following format:
WebAppConnection [connection name] [provider] [host: port]
WebAppDeploy [application name] [connection name] [url path]
The connection name specifies the connection name. The provider can only be warp, and the port must be consistent with the last few lines of your tomcat configuration file server. xml;

The application name is the same as the application name deployed in tomcat. The url path specifies the url to access this application. For example, you can use http: // localhost/examples/to access the examples application in tomcat.

# If you do not want to access your content through http: // ip/xxx/, you can modify the ROOT application in the server. xml file of tomcat, and then in the httpd. conf file of apache

In the WebAppConnection warpConnection warp localhost: 8008
Add a WebAppDeploy ROOT warpConnection/



(4) Test the configuration again and run the following command:
Apachectl configtest
If Syntax OK appears, the installation is successful.
If the following error message is displayed:
Syntax error on line 1038 of/etc/httpd/conf/httpd. conf:
Invalid virtual host name
Modify the httpd. conf file, find the row where # ServerName is located, and add the following content below it.
ServerName localhost: 8008 # specify the server name and port. Note that the port number is 8008 instead of 8080, because port 8008 is specially used to encapsulate mod_webapp

(5) Check the configuration in the $ CATALINA_HOME/conf/server. xml file. By default
The related information is commented out. Search 8008 and find In that section" "Delete All,
In this way, Tomcat will be initialized at startup.

7. Integration Test

Restart all services
./Shutdown. sh
./Startup. sh
/Etc/rc. d/init. d/httpd restart

Enter the following address in the browser:
Http: // server IP/examples/jsp/index.html. If a webpage is displayed, the installation is successful.

Enter the following address in the browser:
Http: // server IP/examples/jsp/jsptoserv/jsptoservlet. jsp if normal webpage and time can be displayed, then jsp and Servlet are installed

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.