SurfingBean wrote 'spend a few days to explore apache and Tomcat's integration under Linux, slightly gain. Write out with you, I hope to inspire you.
There are many similar articles on the Internet, which focuses on explaining that some beginners are difficult to understand, and talk about their experience.
I spent a few days to explore the integration of Apache and Tomcat under Linux, slightly gain. Write out to share with you, I hope to inspire you.
There are many similar articles on the Internet, which focuses on explaining that some beginners are difficult to understand, and talk about their experience.
1. Prepare files and decompressed to / temp /:
APR-0.9.1.tar.gz
httpd-2.0.40.tar.gz
J2SDK-1_4_1_02-linux-i586-rpm.bin (directly run)
JAKARTA-TOMCAT-4.1.18.tar.gz
JAKARTA-TOMCAT-Connectors-4.1.27-src.tar.gz
Note; these files are slow to download on its official website, but they can be found on the Internet.
The resulting Jakarta-Tomcat-4.1.18 / and Jakarta-Tomcat-Connectors-4.1.27-SRC / Copy to / OPT /
#cp -r jakarta-tomcat-4.1.18 / / opt /
#CP -R jakarta-tomcat-connectors-4.1.27-src / / opt /
2. Install JDK (Java Development Kit)
#rpm -ivh j2sdk-1_4_1_02-fcs-linux-i586.rpm
The default installation directory is /usr/java/j2sdk1.4.1_02/
3. Set an environment variable:
In / etc / profile, join:
#java environment variable settings
Java_home = / usr / java / j2sdk1.4.1_02
Export java_home
ClassPath = $ java_home / lib: $ java_home / jre / lib
Export ClassPath
Catalina_base = / opt / jakarta-Tomcat-4.1.18
Export catalina_base
Catalina_Home = / OPT / JAKARTA-TOMCAT-4.1.18
Export catalina_home
PATH = $ java_home / bin: $ java_home / jre / bin: $ PATH: $ HOME / BIN
It is necessary to restart to take effect.
Test JDK: Run
# java -version
# Javac -Version
JDK installation is successful when seeing version information
Test Tomcat: Run
# /opt/jakarta-tomcat-4.1.18/bin/startup.sh
Enter: http: // ip address: 8080
You can see the Tomcat page is installed successfully.
4. Install Apache
Enter Apache's decompression directory /Temp/httpd-2.0.40/
The config.Layout file determines each of the various styles of Apache's installation directory. Here, Redhat will be selected. It is recommended to change the prefix of Redhat in the file to / etc / httpd.
# ./configure --enable-layout = redhat --enable-module = so
- Generate a makefile file. Here, the RedHat setting in the config.layout file is selected. And compile with DSO (Dynamic Shared Object).
# Make
- Compilation
# make install
- Installation
Test Apache: Run
# / etc / httpd / sbin / apachectl start
Enter: http: // ip address in the browser
It can be installed correctly.
5. Compile Jakarta-Tomcat-Connectors
# cp -r /temp/apr-0.9.1/ /opt/jakarta-tomcat-connectors-4.1.27-src/webapp/APR - copy APR-0.9.1 / Directory and rename
# cd /opt/jakarta-tomcat-connectors-4.1.27-src/webapp
- Go to the directory
# ./support/buildconf.sh
- Generate compilation profile
# ./configure --with-apxs = / etc / httpd / sbin / apxs
- Generate makefile compilation files. Here, the location of the APXS file is indicated. It may vary depending on the Apache installation directory.
# Make
- Compilation MOD_WEBAPP.SO
# cp apache-2.0 / mod_webapp.so / etc / httpd / lib / apache /
- Copy mod_webapp.so. The destination directory here can be arbitrarily specified, but must correspond to the settings in HTTPD.CONF.
Here is a habitual location.
6. Modify /etc/httpd/conf/httpd.conf
1) After # Dynamic Shared Object (DSO) Support, add the following item (left and right in line 230):
LoadModule WebApp_module /etc/httpd/lib/apache/mod_webapp.so
- Load us the module MOD_WEBAPP that has just been compiled
2) Add the following contents in the end of the file:
WebAppConnection WarpConnection Warp localhost: 8008
WebAppDeploy Examples WarpConnection / Examples / EXAMPLES /
- Renalized to Tomcat and set virtual directory / Examples /
If the computer has its own domain name (can be set in the / etc / hosts file), use it to replace localhost and at ServerName
(Probably at 290 rows)
ServerName Your_Domain_name: 80
3) In order to make Apache better support Chinese, change AddDefaultCharset ISO-8859-1 to
AddDefaultCharset Off
4) Syntax check: run
# / etc / httpd / sbin / apachectl configtest
If you display Syntax OK, the syntax is correct
Otherwise, depending on the prompt, check if httpd.conf is correct.
5) Modify /opt/jakarta-tomcat-4.1.18/conf/server.xml file
By default, information related to 8008 port is commented, and you need to delete the comment.
If it is a higher version than Tomcat4.1.18, there may be no content. Then copy the following text to the file last
Before the last line:
Port = "8008" MINPROCESSORS = "5" maxprocessors = "75"
Enablelookups = "true" AppBase = "WebApps"
Acceptcount = "10" debug = "0" />
Name = "apache" debug = "0">
Prefix = "apache_log." SUFFIX = ". TXT"
TimeStamp = "true" />
7. Overall test
run:
# /opt/jakarta-tomcat-4.1.18/bin/shutdown.sh
# /opt/jakarta-tomcat-4.1.18/bin/startup.sh
# / etc / httpd / sbin / apachectl restart
Enter the following address in your browser
HTTP: // Server IP / Examples / JSP / INDEX.HTML, if you can display a normal page, then install successfully then select several JSP examples, and the dynamic web page is displayed.
8. Some additions:
1) The integration of Apache and Tomcat is not perfect. The JSP dynamic web page can only access the Apache's virtual directory, that is, not accessible.
Apache's dynamic web page in the default directory. Which people know the solution, but also hope to enlighten me.
2) If you want to run an HTTPD service when you start on your computer, you can join these lines in the /etc/rc.d/rc.local file:
#start apache
/ etc / httpd / sbin / apachectl start
#start Tomcat
/opt/jakarta-tomcat-4.1.18/bin/startup.sh
3) In order to receive external access, don't forget to open the port of the firewall HTTP:
# setup
-> FireWall Configuration
4) In the process of experimentation and writing, refer to the articles of many big cows, thank you here. It is inevitable that there is a fallacy and omissue, but also hope?
Criticism refers to.
Surfingbean
Surfingbean@yahoo.com
'