1. Environment
Apache:
Apache_2.2.11-win32-x86-no_ssl.msi (download http://httpd.apache.org/download.cgi)
Tomcat: Tomcat 5.5.9 or above. Recommended download
Http://tomcat.apache.org/download-60.cgi
Mod_jk: mod_jk-apache-2.2.4.so download
Http://tomcat.apache.org/download-connectors.cgi
(This is not my version. It should be OK. If not, ask me)
It is best to install Tomcat without installation. I am familiar with Tomcat. Apache is directly installed.
2. installation, configuration, and debugging
A. install Apache. By default, It is enough.
B. It is better to install Tomcat without installation.
C. Copy the mod_jk-apache-2.2.4.so to the modules directory of Apache installation.
D. Modify Apache HTTP. conf and add it at the end.
Loadmodule jk_module modules/mod_jk-apache-2.2.4.so # This file name, with the name you just copied a jkmount/*. jsp Controller
Worker. list = controller, worker AT1 # Server LIST #======= worker AT1 ======= worker. tomcat1.port = 8009 # ajp13 port number, in Tomcat server. xml configuration. The default value is 8009.
Worker. tomcat1.host = localhost # Tomcat host address. If not, enter the IP address
Worker. tomcat1.type = ajp13
Worker. tomcat1.lbfactor = 1 # server weighting ratio. The higher the value, the more requests are allocated.
E: Modify the Tomcat main configuration file server. xml
Find the configuration for the comment 8009. Remove comments.
F: Test
Open tomcat, restart Apache, and access the application for testing.
If the app in the original test Tomcat is http: // localhost: 8080/OA
Now test http: // localhost/OA. If both the original and current are normal, it will be OK.
It is easy to write and written based on actual configuration experience. There is no step-by-step debugging.
Post: http://www.oecp.cn/hi/single/blog/115
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------------
Apache URL rewrite path rewriting integrates Apache + Tomcat Load Balancing
Path rewriting is useful. The most basic and important goal is Seo (Search Engine Optimization). As for more purposes, I will not go into detail. Using Apache URL rewrite path rewriting is a convenient and effective method. You can rewrite the path to minimize program code changes.
This article is not just about path rewriting. It describes the path rewriting process from the project and practice.
In my previous article, I described how to handle Server Load balancer. See apahce (2.2.11 edition) + Tomcat + mod_jk integration and basic load balancing practices in windows. This article is rough. This article is based on the previous article and carries out subsequent operations.
The rewrite path rewriting process and configuration method of Apache URL are provided here.
1. Find # loadmodule rewrite_module modules/mod_rewrite.so in httpd. conf.
Remove the previous. To make the path rewriting take effect.
2. Add the path rewriting configuration at the end of the configuration file.
<Ifmodule mod_rewrite.c>
Rewriteengine on
Rewriterule ^/MyApp/(. *) $/$1 [L, pt]
Rewriterule ^/search/(. *) \. html $/search. jsp \? Key = $1 [L, pt]
Rewriterule ^/search/([0-9] +)-([0-9] +)-([0-9] + )-(. *)\. htm $/search2 \. JSP \? Key = $1 & Order = $2 & Price = $3 & page = $4 [L, pt]
</Ifmodule>
Note:
A. rewriteengine on is required. Make the path rewrite take effect.
B. The rewriterule ^/MyApp/(. *) $/$1 [L, pt] Clause filters out the MyApp. If the server configuration is not properly applied, you can use the web site to open the website and easily see the application name. If the address bar contains the application name when you access the application, you can remove the application name. That is, the user cannot see it. MyApp is your application name. Do not copy it directly.
C. I noticed (. *) $1. Something in a bracket corresponds to a $ placeholder. For more information about the syntax, see professional documents. Here is a simple example.
Rewriterule ^/search/([0-9] +)-([0-9] +)-([0-9] + )-(. *)\. htm $/search2 \. JSP \? Key = $1 & Order = $2 & Price = $3 & page = $4 [L, pt]
You can see this sentence. There are a total of 4 (), followed by four $ *, relative. Location is important. Location refers to $1, $2, the first and second positions.
D. Check [L, pt]. This indicates that l is the last rule. For more information, see the professional documentation. I usually use these two [L, pt]. I think this is almost the same.
3. Apache path rewriting is a rewriting of dynamic paths. You can also see the last configuration. The result is that HTML documents are displayed in the address bar during user access, but JSP is used for the background Tomcat server. For Apache + Tomcat configuration. Read the previous article.
The Apache URL rewrite path will be rewritten here. A series of articles will be added later: Apache + Tomcat Single IP, multi-domain configuration practices.
Post: http://www.oecp.cn/hi/single/blog/124
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Apache + Tomcat Single IP, multi-domain configuration practices. Practical configuration experience
Tags: Apache + Tomcat multi-domain configuration Apache Multi-Domain Configuration
I believe many people will encounter that they only have one server, but want to have several applications on one server. Allow user access. At the same time, users do not want to use URL-based forwarding or the like, which is not a good user experience.
If IIS is used for configuration, it is easy, but the JSP series do not fully comply with their own practices. You can also configure a single IP address with multiple domain names in Apache or Tomcat clusters in your own mode.
Requirements:
1. Static pages are responded by Apache, and dynamic JSP pages are processed by Tomcat.
2. There is only one server, but several JSP applications are required to run. We hope that the customer can access it through the domain name.
3. Do not use URL forwarding, which is not good for users and is not conducive to Seo
Configuration
1. Apache + Tomcat configuration.
See previous articles:
A. Apache + Tomcat basic configuration: apahce (2.2.11) + Tomcat + mod_jk integration in windows, basic load balancing practices
B. Static path Rewriting: Apache URL rewrite path rewriting integrates Apache + Tomcat Load Balancing
2. Find the main configuration file HTTP. conf in the Apache installation file.
Find: # include CONF/extra/httpd-vhosts.conf
Remove the previous #. Make the VM configuration take effect.
3. In the main configuration file, HTTP. conf
Find jkmount/* Controller
Comment out. This process does not exist if it is not followed by the first article in my series.
4. Open the httpd-vhosts.conf under extra.
Delete all, refer to the following content to write
Namevirtualhost *: 80
<Virtualhost *: 80>
Serveradmin dugang@baiyyy.com.cn
DocumentRoot D:/APP/test
Servername test.baiyyy.com.cn
Serveralias test.baiyyy.com.cn
<Directory "D:/APP/test">
Options indexes followsymlinks
AllowOverride all
Order allow, deny
Allow from all
</Directory>
# This sentence must be added. Otherwise, Tomcat will not be used for JSP processing. This statement cannot be in the master configuration file. It must be in this host configuration file.
Jkmount/* controller #Note that all requests are forwarded to Tomcat for load balancing as mentioned in my first article. If not according to my previous configuration. You cannot find this sentence. You do not need to add. If this sentence is not added, dynamic pages cannot be processed. You can only access static pages.
</Virtualhost>
# Test2.20.yyy.com.cn
<Virtualhost *: 80>
Serveradmin dugang@baiyyy.com.cn
DocumentRoot G:/devplateform/Koa
Servername test2.baiyyy.com.cn
Serveralias test2.baiyyy.com.cn
<Directory "G:/devplateform/Koa">
Options indexes followsymlinks
AllowOverride all
Order allow, deny
Allow from all
</Directory>
</Virtualhost>
4. Notes
See the red and bold fonts in the above Code. Special attention.
5. Required Before Configuration
See the first two articles in my series. Otherwise, the configuration is unsuccessful.
6. domain name resolution configuration is not described here. Generally, network administrators can handle this problem.
You can solve this problem through this series of articles:
1. Apache + Tomcat server Load balancer and cluster configuration. Optimize your server configurations.
2. Rewrite the Apache path. Optimize Seo for your search engine to make a difference. It also makes your website links more friendly and easier to be crawled by search engines.
3. configure a single IP address and multiple domain names in Apache to make full use of your domain name and Server IP address. You can use tomcat to process dynamic pages, whether purely static HTML or dynamic JSP application websites, to configure multiple domain names.
Reprinted, please note this site address: http://www.po-soft.com/blog/single/125.html