GCC4.1 + apache2 + tomcat5 + mod_jk Integration

Source: Internet
Author: User
Tags apache log
GCC4.1 + apache2 + tomcat5 + mod_jk integration-Linux Enterprise Application-Linux server application information. For more information, see the following. This article is for reference only

WEB installation documentation
1. Install GCC4.1.0 (optional)
: Ftp://linuxforum.net/pub/gcc/releases/gcc-4.1.0/gcc-4.1.0.tar.bz2
# Tar jxf gcc-4.1.0.tar.bz2
# Mkdir gcc-build; cd gcc-build
# ../Gcc-4.1.0/configure -- prefix =/usr/local/gcc4.1 & make install
# Cd/usr/bin; mv gcc _ gcc
# Ln-s/usr/local/gcc4.1/bin/gcc
# Gcc-v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.1.0/configure -- prefix =/usr/local/gcc4.1
Thread model: posix
Gcc version 4.1.0
If the above output is available, the gcc compilation and installation are successful.
2. Compile and install APACHE2.2
Download apache2.2 source package http://mirror.vmmatrix.net/apache/httpd/httpd-2.2.0.tar.bz2

2.1. Extract
# Tar jxvf httpd-2.2.0.tar.bz2
# Cd httpd-2.2.0
2.2. modify some source code
# Vi server/mpm/worker. c
Find the following lines and change them to the following values to modify the maximum number of threads and the maximum number of clients supported by apache in the source code.
# Define DEFAULT_SERVER_LIMIT 256
# Define MAX_SERVER_LIMIT 40000
# Define DEFAULT_THREAD_LIMIT 256
# Define MAX_THREAD_LIMIT 40000
2.3. Compile the configuration
Optimize compilation options and configure modules that can be loaded by apache
# CFLAGS = "-O6-mpentiumpro-fomit-frame-pointer" CXX = gcc CXXFLAGS = "-O6-mpentiumpro-fomit-frame-pointer-felide-constructors-fno-Restrictions tions- fno-rtti "\
>./Configure -- prefix =/usr/local/apache2.2 -- enable-mod-shared = all \
> -- Enable-so -- with-mpm = worker -- enable-deflate \
> -- Enable-cache -- enable-disk-cache -- enable-mem-cache -- enable-file-cache \
> -- Enable-proxy -- enable-suexec
2.4. Compilation and Installation
# Gmake & make install
3. Optimize apache configuration options
3.1. Modify MPM (Multi-Channel processor) Parameters
# Cd/usr/local/apache2.2
# Vi conf/extra/httpd-mpm.conf
Find the following option and change it to the corresponding value


ServerLimit 64
ThreadLimit 128
StartServers 8
MaxClients 8192
MinSpareThreads 50
Maxsparethread s 256
ThreadsPerChild 128
MaxRequestsPerChild 0

3.2. Modify the sub-process owner of apache2.2
# Vi/usr/local/apache2.2/conf/httpd. conf
Change daemon to nobody.
User nobody
Group nobody
3.3. Check the syntax and establish soft links
# Vi/usr/local/apache2.2/conf/httpd. conf
Add the following line to the main configuration file httpd. conf. The purpose of this line is to divide the apache function configuration into small files for ease of modification and transplantation.
# Include conf/Includes/*. conf
Run the syntax check command to check the syntax. If an error occurs, continue to adjust it.
#./Bin/apachectl-t
If no error occurs, create a soft link in the/usr/local/directory.
# Ln-s apache2.2 apache2
4. install tomcat and connector JK
The original JK2 module is no longer officially supported, and there is a gap between its performance and the existing jk module. Therefore, we use the JK module instead.
4.1. Download tomcat-5.5.16
Http://apache.justdn.org/tomcat/... omcat-5.5.16.tar.gz

Install JDK by yourself. Remember to set the JAVA_HOME system variable after installation.
# Export JAVA_HOME =/usr/local/jdk1.5.0 _ 06
# Tar apache-tomcat-5.5.16.tar.gz-C/usr/local/
# Mv apache-tomcat-5.5.16 tomcat-5.5.16
# Ln-s tomcat-5.5.16 rjat1
# Cd/usr/local/tomcat1/bin
#./Bin/startup. sh // start tomcat
#./Bin/shutdown. sh // stop tomcat
4.2. Download the JK source code of the connector.

Http://www.apache.org/dist/tomca... s-1.2.15-src.tar.gz
4.3. Compile and install
# Tar zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
# Cd jakarta-tomcat-connectors-1.2.15-src
# Cd jk/native/
#./Configure -- with-apxs =/usr/local/apache2.2/bin/apxs \
> -- With-java-home =/usr/local/jdk15 -- with-java-platform = 2
# Make
# Cp apache-2.0/mod_jk.so/usr/local/apache2.2/modules/
4.4. Configuration
# Cd/usr/local/apache2.2/conf/DES
# Vi mod_jk.conf
Add the following configuration in the text
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Where to find workers. properties
JkWorkersFile/usr/local/apache2/conf/workers. properties
# Where to put jk logs
JkLogFile/usr/local/apache2/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel error
# Select the log format
JkLogStampFormat "[% a % B % d % H: % M: % S % Y]"
# JkOptions indicate to send ssl key size,
JkOptions + ForwardKeySize + ForwardURICompat-ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "% w % V % T"
JkShmFile/usr/local/apache2/logs/mod_jk.shm
# Send jsp, servlet for context * to worker named worker1
JkMount/status/* worker1
JkMount/*. jsp worker1
JkMount/*. jsps worker1
JkMount/*. do worker1
JkMount/* Servlet worker1
JkMount/manager/* worker1
JkMount/ScanIM worker1
JkMount/SendIMMsg worker1
JkMount/CheckMsgServlet worker1
JkMount/TestIM worker1

# Vi ../workers. properties
Add the following configuration in the configuration file:
# Define 1 real worker using ajp13
Worker. list = worker1
# Set properties for worker1 (ajp13)
Worker. worker1.type = ajp13
Worker. worker1.host = 127.0.0.1
Worker. worker1.port = 8009
Worker. worker1.lbfactor = 1
Worker. worker1.cachesize = 10
Worker. worker1.cache _ timeout = 600
Worker. worker1.socket _ keepalive = 1
Worker. worker1.reclycle _ time out = 300
4.5. Test
If you can access files such as. jsp and. do on port 80, the connector is configured successfully.
5. Configure the static page compression output module deflate
This extension module has been dynamically compiled into apache when installing apache. Configure now.
# Cd/usr/local/apache2.2/conf/DES
The Directory of the apache extension configuration file is added above.
# Vi mod_deflate.conf
Add the following statement to the configuration file:

DeflateMemLevel 9
SetOutputFilter DEFLATE
DeflateFilterNote ratio
SetEnvIfNoCase Request_URI \.(? : Gif | jpe? G | png) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI \. pdf $ no-gzip dont-vary

6. Configure the mod_cache Module
# Cd/usr/local/apache2.2/conf/DES
# Vi mod_cache.conf
Add the following statement to the configuration file:



# LoadModule disk_cache_module modules/mod_disk_cache.so

CacheRoot/
CacheSize 256
CacheEnable disk/
CacheDirLevels 5
CacheDirLength 3


LoadModule mem_cache_module modules/mod_mem_cache.so

CacheEnable mem/
MCacheSize 4096
MCacheMaxObjectCount 100
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048


7. check apache running status
Check whether all the configuration files of apache2.2 are correct.
#/Usr/local/apache2.2/bin/apachectl-t
If there is a mistake, modify and adjust again. If not, start apache2.2.
#/Usr/local/apache2.2/bin/apachectl start
Check whether port 80 is listening
# Netstat-apn | grep '\ <80 \>'

Check whether the apache process is running
# Ps aux | grep httpd

Create a test page to test.

8. Install the apache Log Cutting Tool cronolog
# Tar zxf cronolog-1.6.2.tar.gz
# Cd cronolog-1.6.2
#./Configure -- prefix =/usr/local/cronolog & make install

9. apache basic virtual host configuration
For example, the domain name of a machine is www.test.com IP: 59.42.25.35.
Under the apache installation directory
# Vi conf/httpd. conf
Add global VM configuration in the last line
NameVirtualHost 59.42.25.35

# Vi conf/Includes/www.test.com. conf
Create a VM configuration file www.test.com

Order allow, deny
Allow from all


Order deny, allow
Deny from all
Allow from 127.0.0.1 10.10.10.86 59.34.215.86 61.144.207.69




ServerAdmin webmaster@dummy-host.example.com
DocumentRoot/www/www.test.com/www/htdocs
ServerName/www.test.com
ErrorDocument 404/error/404.html
ErrorDocument 500/error/500.html
# LoadModule deflate_module modules/mod_deflate.so
# DeflateFilterNote ratio
LogFormat "% h % l % u % t \" % r \ "%> s % B \" % {Referer} I \ "\" % {User-Agent} I \ "" combined
LogFormat "% h % l % u % t \" % r \ "%> s % B" common
LogFormat "% {Referer} I-> % U" referer
LogFormat "% {User-agent} I" agent
ErrorLog "|/usr/local/cronolog/sbin/cronolog/www // www.test.com/www/logs/% Y/% m/% d/error. log"

# SetEnvIf Request_URI "^ [/im/checkIM] \. jsp | \. do | \. html |. jsps" please_log
SetEnvIf Request_URI "\. jsp" please_log
SetEnvIf Request_URI "\. jsps" please_log
SetEnvIf Request_URI "\. do" please_log
SetEnvIf Request_URI "\. html" please_log
CustomLog "|/usr/local/cronolog/sbin/cronolog/www/www.test.com/www/logs/% Y/% m/% d/% p/access. log "combined env = please_log


10. tomcat basic VM Configuration
In the tomcat installation directory
# Vi conf/server. xml
In the file tagAdd
AutoDeploy = "true" xmlValidation = "false" xmlNamespaceAware = "false">
Suffix = ". log" timestamp = "true"/>
Debug = "0" privileged = "true">




Mail.test.com
Forum.test.com
Group.test.com
Favorites.test.com
Classifieds.test.com
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.