Apache Installation and use

Source: Internet
Author: User

The following is the body content:

First, the Apache installation instructions

1, first open the Apache official website, into the Windows version of the download Address page: http://archive.apache.org/dist/httpd/binaries/win32/and select 2.2.22_no_ SSL version of the MSI installation package download (the high version of this article was written at the end of the official website has not yet provided MSI installation package), as shown:


The download is ready to start installing.

2, run just downloaded a good MSI file (Httpd-2.2.22-win32-x86-no_ssl.msi), the installation process is as follows:


Click Next to continue:






The above network domain, Server name and email address three content if it is used for testing the individual think that there is no problem, but if the real network environment domain name and other parameters are unique, should truthfully fill in, fill in and click Next to continue:


Choose Custom here, you can customize the installation path, and so on, click Next to continue:


The contents of the red box is the Apache installation path, you can click Change changes, other information by default, click Next to continue:


Click Install to start the installation:


The installation process will pop up a few cmd windows, will automatically close, without the tube, and finally:


Click Finish installation completed, start the operation of the input services.msc, you can see that Apache has been registered as a Windows service:


The Apache Monitor is also automatically turned on in the lower-right corner of the Windows taskbar: If the Apache service does not start automatically or starts the Apache service, it pops up a window similar to the following figure:


Indicates that the default 80 port for Apache is already occupied. You can turn off software that consumes 80 of ports, or you can change the default configuration of Apache so that it listens to other ports.


Two, the basic configuration of Apache

Open the Apache installation directory, whose main configuration is in the httpd.conf file under the Conf folder, as shown in the figure:


Open the httpd.conf file with UltraEdit or notepad++ and read from the top down:

1, the 35th line, ServerRoot for Apache installation path, this understanding can, do not care about it;

2, line 46th, Listen 80 Specifies 80 as the default listener port for Apache, where we change to 88 to prevent conflicts with other software that occupies 80 ports. When you are done, start it in the Windows service and you can see no error window. Open the browser and enter http://localhost:88 in the address bar if you see the following message that Apache has been installed and started successfully:


3, line 172th, ServerName set before the installation of the DNS domain name (if there is no domain name on the input IP, remember with the top slogan), #号为注释, here to remove the #, the revised contents are as follows:

ServerName 127.0.0.1:88

After the modification, test the configuration correctly: Open Start menu-All programs, find the Apache HTTP Server 2.2 test Configuration, and run, as shown in figure:


If the contents of the CMD serial port is Syntax OK and Flash, the configuration is no problem, otherwise the message will be prompted and stay 30 before automatic shutdown.

4, the 179th line, DocumentRoot generally for JS, CSS, HTML, PNG, GIF, JPG and other static resource files of the directory, here we define the storage in the D-Disk Apache_statics folder. The revised contents are as follows:

DocumentRoot "D:/apache_statics"

5, line 193th, change the Deny from all to allow from all otherwise, the page prompts forbidden information that is blocked when accessing the static file. The revised content is as follows:


6, the No. 206 line, Directory changes to and documentroot corresponding value of the same, the modified content as follows:

<directory "D:/apache_statics" > 7, Line No. 219, comment out the options Indexes followsymlinks, and append one line of options to None. The effect is set to false in the Conf/web.xml in the listings under Tomcat to avoid listing the directory structure of the service-side resources in the browser.


Three, Apache integrated Tomcat configuration

Apache can complete the default functionality by integrating different modules, such as integrating Tomcat to install the MOD_JK module. By loading this module and the corresponding configuration, Apache can be realized by listening to the specified port (configured with 88 ports above) to resolve the static resource content, dynamic resource content such as JSP, servlet, action to Tomcat to resolve. The details are as follows:

1, first go to the official website Download MOD_JK module, address: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/win32/jk-1.2.31/ Select the latest version of the mod_jk-1.2.31-httpd-2.2.3.so download;

2, copy the mod_jk-1.2.31-httpd-2.2.3.so file to the Apache installation directory Modules folder, the following figure:


3, in the Conf folder (httpd.conf folder) to create a new Workers.properties file, the following figure:


Workers.tomcat_home is the installation path for Tomcat; Workers.java_home is the installation path for JDK; MOD_JK typically uses the AJP13 protocol to connect to Tomcat, using port 8009 by default, which can be used in Tomcat Conf/server.xml, see the following figure:


4, at the end of the httpd.conf to add a piece of code, the following figure (red box):


The above code loads the MOD_JK module and the Workers.properties file and defines the output location (logs/mod_jk.log) of the log file; ServerAdmin, DocumentRoot, ServerName is the same as previously configured; Jkmount specifies that the paths will be handled by Tomcat via the AJP13 protocol, and multiple paths define multiple Jkmount ... ajp13. A URL that starts with a web-inf or ends with a. Action or. JSP or begins with a servlet/will be resolved by Tomcat. Since then, Apache has been consolidated with Tomcat, where the static resource portion of the program is typically deployed to the previously mentioned D:\Apache_Statis folder, while Non-static resources are deployed under Tomcat.

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.