Install Apache httpserver and integrate it with Tomcat for Linux

Source: Internet
Author: User
Tags create directory

 

 

The httpserver version is 2.2.22. For JDK and tomcat installation, see:

Http://blog.csdn.net/supercrsky/article/details/8283200

 

1. Download

Httpserver:

Http://archive.apache.org/dist/httpd/httpd-2.2.22.tar.gz

Tomcat:

Http://archive.apache.org/dist/tomcat/tomcat-7/

Mod_jk:

Http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.23/

2. Install httpd

My tar package is under the/home/zdw/Software Directory, switch to this directory

# Cd/home/zdw/software

Extract

# Tar-zxvf httpd-2.2.22.tar.gz

Enter the decompressed directory

# Cd httpd-2.2.22

Run

#./Configure -- prefix =/usr/local/apache2.2 -- enable-so -- enable-mod-shared

= Most -- With-MPM = worker

 

# -- Prefix = <install_path> indicates that the compiled binary file is installed in the <install_path> directory and replaced with the actual installation path <install_path>, for example, -- prefix =/usr/local/Apache-2.2.15. If this configuration parameter is omitted, it is installed in the/usr/local/apache2 directory by default.

# -- Enable-soSpecify that the dynamic loading module (DSO) supports httpd binary files. This module allows the functional modules of Apache to be compiled separately from the core and dynamically loaded during runtime. With DSO support, you only need to compile the relevant modules when upgrading and adding modules. You do not have to re-compile the entire system. The latest version of Apache compiles this module to the httpd binary file by default. If you are using an earlier version of Apache and need DSO support, you may need to explicitly specify this option.

# -- Enable-mod-shared = <module-List>Specify the module to be compiled in DSO mode. <module-List> indicates the list of module names separated by spaces, all or most. All indicates that all modules are included, and most indicates that most modules are included, for example, -- enable-mod-Share = "Rewrite
Deflate ", -- enable-mod-Share = most
The effect is equivalent to multiple -- enable-<feature> = Share
#
-- With-MPM = <MPM> select the Apache Multi-path processing module, <MPM >={ BEOs | event | worker | prefork | mpmt_os2}, and prefork is the default processing module in UNIX systems, it will run a non-thread-type, pre-derived web server, suitable for systems without thread security library and need to avoid thread compatibility issues, it is the best MPM for each request to be independent from each other, so that if a request fails, it will not affect other requests. Worker is a multi-path processing module that supports mixed multi-thread, multi-process processing. because it uses threads to process requests, it can process massive requests. the overhead of system resources is less than the MPM Based on processes, it also uses multiple processes, and each process has multiple threads to obtain the stability of the process-based MPM. If your system is thread-safe, I suggest using worker instead of prefork, which will improve your system performance.

 

There will be a lot of checking

Compile after completion

# Make

Install

# Make install

Switch to the specified installation directory:

# Cd/usr/local/apache2.2

View the directory content:

# Ls

Switch to the bin directory and start Apache for testing,

#./Apachectl start

Report:

Solution:

Modify the conf/httpd. conf file and remove the comment to # servername.

However, # servername is not found in the httpd. conf file of ubuntu. Use VI to manually

Add servername 127.0.0.1: 80 to httpd. conf to save.

Switch back to/usr/local/apache2.2/bin to run

#./Apachectl start

Enter http: // localhost/in Firefox, and the IT works page is displayed.

Stop

#./Apachectl stop

So far, APACHE-httpserver has been installed successfully.

3. Integrate Apache and tomcat

# Vi CONF/httpd. conf

Find

DocumentRoot "/usr/local/httpd2.2/htdocs"

This is called DocumentRoot or webroot, that is, the release directory. Any project published under this directory will be loaded into a standard web project when the apache service is enabled, now let's move this webroot to our own release directory.

DocumentRoot "/usr/local/www"

Create directory:

# Mkdir WWW

Copy the downloaded mod_jk-1.2.23-apache-2.2.x-linux-i686.so to modules

# Cp mod_jk-1.2.23-apache-2.2.x-linux-i686.so/usr/local/httpd2.2/modules/

Create workers. Properties

# Touch workers. Properties

# Vi workers. Properties

Add the following content:

workers.tomcat_home=/opt/tomcat/workers.java_home=/usr/jdk1.7.0_09/ps=/worker.list=ajp13worker.ajp13.port=8009worker.ajp13.host=localhostworker.ajp13.type=ajp13

The key is the following two sentences:

Loadmodule jk_module modules/mod_jk-1.2.31-httpd-2.2.3.so

Jkworkersfile CONF/workers. Properties

Representative:

Ü load an additional plug-in to connect to Tomcat.

Ü the configuration parameter description during connection is located in a workers. properties file under the/conf directory of the Apache installation directory. mod_jk generally uses the ajp13 protocol for connection and uses Tomcat port 8009.

 

Edit the httpd. conf file

# Vi/CONF/httpd. conf

Add the following lines to the end of the file:

LoadModule jk_module modules/mod_jk-1.2.23-apache-2.2.x-linux-i686.soJKWorkersFile conf/workers.propertiesJkLogFile logs/mod_jk.log<VirtualHost *>ServerAdmin localhostDocumentRoot usr/local/wwwServerName localhostDirectoryIndex index.html index.htm index.jsp index.actionErrorLog logs/shsc-error_log.txtCustomLog logs/shsc-access_log.txt commonJkMount /*WEB-INF ajp13JkMount /*j_spring_security_check ajp13JkMount /*.action ajp13JkMount /servlet/* ajp13JkMount /*.jsp ajp13JkMount /*.do ajp13</VirtualHost> 

Copy the project we want to test to the/opt/tomcat/webapps and/usr/local/WWW directories respectively.

Restart Tomcat and apahce.

Open javasefox to access our project: http: // localhost/Composite

Report:

However, http: // localhost: 8080/composite is normal.

Edit CONF/httpd. conf and find:

<Directory />    Options FollowSymLinks    AllowOverride None    Order deny,allow    Deny from all</Directory>

Change deny to allow as follows:

<Directory />    Options FollowSymLinks    AllowOverride None    Order deny,allow    Allowfrom all</Directory>

After saving, restart Apache before accessing:

Now, Apache and tomcat are integrated successfully.

 

The above instances are successfully tested in ubuntu11.04.

 

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.