GCC4.1 + apache2+tomcat5 + mod_jk整合(轉)
GCC4.1 + apache2+tomcat5 + mod_jk整合(轉)[@more@]本文僅做參考
WEB安裝文件
1. GCC4.1.0安裝(可選)
下載地址:
# 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 && make install
# cd /usr/bin; mv gcc _gcc
# ln -s /usr/local/gcc4.1/bin/gcc 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
如果有以上的輸出,說明gcc編譯安裝成功.
2. APACHE2.2編譯安裝
下載apache2.2原始碼包
2.1. 解壓縮
# tar jxvf httpd-2.2.0.tar.bz2
# cd httpd-2.2.0
2.2. 修改部分原始碼
# vi server/mpm/worker/worker.c
找到下面幾行,並改成如下的數值,其目的是在原始碼中修改apache可支援的 最大執行緒數和最大客戶端數目。
# define DEFAULT_SERVER_LIMIT 256
# define MAX_SERVER_LIMIT 40000
# define DEFAULT_THREAD_LIMIT 256
# define MAX_THREAD_LIMIT 40000
2.3. 編譯配置
最佳化編譯選項及配置apache可載入的模組
# CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
> ./configure --prefix=/usr/local/apache2.2 --enable-mods-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. 編譯及安裝
# gmake && make install
3. 最佳化apache配置選項
3.1. 修改MPM(多道處理器)引數
# cd /usr/local/apache2.2
# vi conf/extra/httpd-mpm.conf
找到如下選項,並改成對應的數值
ServerLimit 64
ThreadLimit 128
StartServers 8
MaxClients 8192
MinSpareThreads 50
MaxSpareThreads 256
ThreadsPerChild 128
MaxRequestsPerChild 0
3.2. 修改apache2.2子程式所有者
# vi /usr/local/apache2.2/conf/httpd.conf
把daemon改為nobody
User nobody
Group nobody
3.3. 語法檢查及建立軟連結
# vi /usr/local/apache2.2/conf/httpd.conf
在主配置檔案httpd.conf新增如下一行,這樣做的目的是把apache的功能配置分成小檔案,便於修改和移植
# Include conf/Includes/*.conf
執行語法檢查命令檢查語法,出現錯誤後繼續調整。
# ./bin/apachectl -t
沒有錯誤後在 /usr/local/ 目錄下建立軟連結
# ln -s apache2.2 apache2
4. 安裝tomcat和聯結器JK
原先的JK2模組已經不被官方支援,而且在效能上和現有的jk模組也有差距,所以改用JK模組。
4.1. 下載tomcat-5.5.16
JDK自行安裝,安裝後要記得設定 JAVA_HOME系統變數。
# export JAVA_HOME=/usr/local/jdk1.5.0_06
# tar zxf 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 tomcat1
# cd /usr/local/tomcat1/bin
# ./bin/startup.sh //啟動tomcat
# ./bin/shutdown.sh //停止tomcat
4.2. 下載聯結器JK原始碼
4.3. 編譯安裝
# 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. 配置
# cd /usr/local/apache2.2/conf/Includes
# vi mod_jk.conf
在文字中新增如下配置
# 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
在配置檔案中新增如下配置
# 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_timeout=300
4.5. 測試
如果在80埠能訪問.jsp,.do等檔案說明配置聯結器成功。
5. 配置靜態頁面壓縮輸出模組deflate
這個擴充套件模組在安裝apache的時候已經動態的編譯到apache裡去了。現在進行配置。
# cd /usr/local/apache2.2/conf/Includes
上面新增的是apache擴充套件配置檔案的目錄
# vi mod_deflate.conf
在配置檔案裡新增如下語句
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. 配置mod_cache模組
# cd /usr/local/apache2.2/conf/Includes
# vi mod_cache.conf
在配置檔案裡新增如下語句
#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. 檢查apache執行狀態
檢查apache2.2所有配置檔案是否有錯誤
# /usr/local/apache2.2/bin/apachectl -t
有錯繼續修改調整,沒有就啟動apache2.2
# /usr/local/apache2.2/bin/apachectl start
檢視80埠是否在監聽
# netstat -apn|grep '<80>'
檢視apache程式是否執行
# ps aux|grep httpd
建立測試頁面測試.
8. 安裝apache日誌切割工具cronolog
# tar zxf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure --prefix=/usr/local/cronolog && make && make install
9. apache基本虛擬主機配置
比如某一機器 域名 IP: 59.42.25.35
在apache安裝目錄下
# vi conf/httpd.conf
在最後一行新增全域性虛擬主機配置
NameVirtualHost 59.42.25.35
# vi conf/Includes/
建立 虛擬主機 配置檔案
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
DocumentRoot /www/ /www/htdocs
ServerName /
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/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/logs/%Y/%m/%d/%p/access.log" combined env=please_log
10. tomcat基本虛擬主機配置
在tomcat安裝目錄下
# vi conf/server.xml
在檔案的標籤 新增
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
WEB安裝文件
1. GCC4.1.0安裝(可選)
下載地址:
# 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 && make install
# cd /usr/bin; mv gcc _gcc
# ln -s /usr/local/gcc4.1/bin/gcc 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
如果有以上的輸出,說明gcc編譯安裝成功.
2. APACHE2.2編譯安裝
下載apache2.2原始碼包
2.1. 解壓縮
# tar jxvf httpd-2.2.0.tar.bz2
# cd httpd-2.2.0
2.2. 修改部分原始碼
# vi server/mpm/worker/worker.c
找到下面幾行,並改成如下的數值,其目的是在原始碼中修改apache可支援的 最大執行緒數和最大客戶端數目。
# define DEFAULT_SERVER_LIMIT 256
# define MAX_SERVER_LIMIT 40000
# define DEFAULT_THREAD_LIMIT 256
# define MAX_THREAD_LIMIT 40000
2.3. 編譯配置
最佳化編譯選項及配置apache可載入的模組
# CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
> ./configure --prefix=/usr/local/apache2.2 --enable-mods-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. 編譯及安裝
# gmake && make install
3. 最佳化apache配置選項
3.1. 修改MPM(多道處理器)引數
# cd /usr/local/apache2.2
# vi conf/extra/httpd-mpm.conf
找到如下選項,並改成對應的數值
ServerLimit 64
ThreadLimit 128
StartServers 8
MaxClients 8192
MinSpareThreads 50
MaxSpareThreads 256
ThreadsPerChild 128
MaxRequestsPerChild 0
3.2. 修改apache2.2子程式所有者
# vi /usr/local/apache2.2/conf/httpd.conf
把daemon改為nobody
User nobody
Group nobody
3.3. 語法檢查及建立軟連結
# vi /usr/local/apache2.2/conf/httpd.conf
在主配置檔案httpd.conf新增如下一行,這樣做的目的是把apache的功能配置分成小檔案,便於修改和移植
# Include conf/Includes/*.conf
執行語法檢查命令檢查語法,出現錯誤後繼續調整。
# ./bin/apachectl -t
沒有錯誤後在 /usr/local/ 目錄下建立軟連結
# ln -s apache2.2 apache2
4. 安裝tomcat和聯結器JK
原先的JK2模組已經不被官方支援,而且在效能上和現有的jk模組也有差距,所以改用JK模組。
4.1. 下載tomcat-5.5.16
JDK自行安裝,安裝後要記得設定 JAVA_HOME系統變數。
# export JAVA_HOME=/usr/local/jdk1.5.0_06
# tar zxf 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 tomcat1
# cd /usr/local/tomcat1/bin
# ./bin/startup.sh //啟動tomcat
# ./bin/shutdown.sh //停止tomcat
4.2. 下載聯結器JK原始碼
4.3. 編譯安裝
# 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. 配置
# cd /usr/local/apache2.2/conf/Includes
# vi mod_jk.conf
在文字中新增如下配置
# 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
在配置檔案中新增如下配置
# 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_timeout=300
4.5. 測試
如果在80埠能訪問.jsp,.do等檔案說明配置聯結器成功。
5. 配置靜態頁面壓縮輸出模組deflate
這個擴充套件模組在安裝apache的時候已經動態的編譯到apache裡去了。現在進行配置。
# cd /usr/local/apache2.2/conf/Includes
上面新增的是apache擴充套件配置檔案的目錄
# vi mod_deflate.conf
在配置檔案裡新增如下語句
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. 配置mod_cache模組
# cd /usr/local/apache2.2/conf/Includes
# vi mod_cache.conf
在配置檔案裡新增如下語句
#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. 檢查apache執行狀態
檢查apache2.2所有配置檔案是否有錯誤
# /usr/local/apache2.2/bin/apachectl -t
有錯繼續修改調整,沒有就啟動apache2.2
# /usr/local/apache2.2/bin/apachectl start
檢視80埠是否在監聽
# netstat -apn|grep '<80>'
檢視apache程式是否執行
# ps aux|grep httpd
建立測試頁面測試.
8. 安裝apache日誌切割工具cronolog
# tar zxf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure --prefix=/usr/local/cronolog && make && make install
9. apache基本虛擬主機配置
比如某一機器 域名 IP: 59.42.25.35
在apache安裝目錄下
# vi conf/httpd.conf
在最後一行新增全域性虛擬主機配置
NameVirtualHost 59.42.25.35
# vi conf/Includes/
建立 虛擬主機 配置檔案
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
DocumentRoot /www/ /www/htdocs
ServerName /
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/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/logs/%Y/%m/%d/%p/access.log" combined env=please_log
10. tomcat基本虛擬主機配置
在tomcat安裝目錄下
# vi conf/server.xml
在檔案的標籤 新增
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-950866/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 安裝配置Tomcat + Apache + mod_jk(轉)TomcatApache
- CentOS-6.5-64bit 原始碼安裝mod_jkCentOS原始碼
- MQ和WEBSPHERE整合 (轉)MQWeb
- 整合MQ和WEBSPHERE (轉)MQWeb
- CentOS-6.5-64bit 通過mod_jk連線Apache和TomcatCentOSApacheTomcat
- linux命令大整合_轉摘Linux
- 應用整合的尷尬 (轉)
- Apache使用mod_jk/mod_proxy模組實現代理、負載均衡的配置Apache負載
- 玩轉iOS開發:Touch ID整合iOS
- 轉享:Oracle勾勒SUN整合計劃Oracle
- 整合專案中的風險管理 (轉)
- 實戰apache+tomcat整合(轉)ApacheTomcat
- Oracle 承諾整合Fusion的安全特性(轉)Oracle
- Profinet轉ModbusTCP:從站裝置轉換與整合案例TCP
- iOS整合FFmpeg及視訊格式轉碼iOS
- Spring Cloud Gateway 整合Eureka路由轉發SpringCloudGateway路由
- FreeBSD 整合Unix和Windows的方式(轉)Windows
- JB4 與 WebLogic 的整合 (轉)Web
- linux下Acrobat和mozilla的整合(轉)LinuxBAT
- Flume 整合 Kafka_flume 到kafka 配置【轉】Kafka
- 【高可用HA】Apache (4) —— Mac下配置Apache Httpd負載均衡(Load Balancer)之mod_jkApacheMachttpd負載
- 玩轉 iOS 開發:整合 AliPay – 支付寶iOS
- 玩轉 iOS 開發:整合 AliPay - 支付寶iOS
- 玩轉iOS開發:整合 WeChat SDK - 支付篇iOS
- 銀行業系統整合人員分析 (轉)行業
- FREEBSD下使用crunch整合編譯程式(轉)編譯
- 實戰apache+tomcat+mod_jk整合(轉)ApacheTomcat
- CRM與ERP的整合與關係(轉)
- BPR與ERP的理性整合應用(轉)
- Eclipse+Tomcat整合開發servlet (轉)EclipseTomcatServlet
- 系統整合專案實施的管理(轉)
- 整合LAMP品牌 開源軟體崛起之路(轉)LAMP
- FreeBSD 下使用crunch整合編譯程式(轉)編譯
- 整合struts和hibernate開發嚮導 (轉)
- 讓BPM與ERP系統更好的整合(轉)
- SAP與Borland合作 ,整合JAVA開發環境 (轉)Java開發環境
- 淺談CPC系統與ERP的整合 (轉)
- 【轉載】基於 Docker 的 PHP 整合環境 dnmpDockerPHP