How to compile and Configure in Apache

Source: Internet
Author: User
Article Title: how to compile and Configure in Apache. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The./Configure file is a frequently forgotten Apache tool. This article describes how to use./Configure for compiling and configuration to avoid repeated operations during each Apache compilation. This article compares the advantages and disadvantages of the conventional method and the use of./Configure and how to manually edit the preparation file for compilation and configuration.
  
   I. Comparison of advantages and disadvantages
We know that configure is used to prepare Apache compilation options. However, we can also use Configure. Note the difference between the two: the commonly used preparation tool is "configure" starting with lowercase c. here we will discuss "Configure" starting with an uppercase C.
  
After the Apache source code is Unbound, the configure script is located under the top-level Directory. Generally, follow these steps:
  
Tar-zvxf apache_1.3.14.tar.gz
  
Cd apache_1.3.14
  
./Configure -- prefix =/usr/local/apache
  
Make
  
Make install
  
Configure is the script in the src subdirectory. Its parameters are not specified through the command line, but are specified in a Configuration file named Configuration. Apache provides a default Configuration template file Configuration. tmpl, which contains common default Configuration values.
  
The default installation process with Configure is as follows:
  
Tar-zvxf apache_1.3.14.tar.gz
  
Cd apache_1.3.14/src
  
Cp-f Configuration. tmpl Configuration
  
Vi Configuration
  
... Modify the default configuration value if necessary
  
./Configure
  
Make
  
Make install
  
Disadvantages
  
Using Configure for preparation has several obvious disadvantages, at least for beginners.
  
First, this preparation method is not widely known. Anyone who knows about open-source software may be familiar with its configure script after unlocking the source code and entering its directory, but it often does not go to the src subdirectory to find anything else.
  
Even if you know that you can use Configure for compilation and preparation, the Configuration file itself may become a small obstacle. This is because, although the description contained in the Configuration file is quite complete, each line has a wealth of annotations to illustrate its role, but this file is too large, there are many options that most people will never want to customize.
  
Finally, although there is little information about the differences between the two preparation methods, it seems that it is better for beginners to use configure, and Configure is only suitable for experienced users. Although this is not a real drawback, it makes many users stop and dare not try.
  
Advantages
  
The biggest advantage of using Configure for compilation and preparation is that it makes it easy for us to save specific configuration information and then use it again. you don't need to remember the lengthy configure command line options.
  
For example, the configure command I used when compiling Apache last time is as follows:
  
./Configure -- prefix =/usr/local/apache -- enable-module = most
  
-- Enable-shared = max -- enable-module = auth_dbm
  
-- Enable-module = auth_mysql
  
This should be a relatively simple compilation. The problem is that, even if I enter the above command, I need to view the syntax of various parameters and try to remember the names of each module. For most people, this is not a very important issue, but because I often need to reconstruct Apache, this issue is quite prominent.
  
Configure also has its advantages. it will actually generate a configuration file under the src Directory. we can save this file for future reference. This file is src/Configuration. apaci.
  
If we construct Apache for the purpose of testing, and then construct Apache in the same way on the officially running system, this function of configure will be very useful. At this point, we only need to copy a Configuration. apaci file, copy it to the running server, and then compile the Apache server with this file.
  
It should be noted that, although the Configuration options are provided by the Configuration file by default, we can use the-file parameter to specify another file:
  
./Configure-file Configuration. saved_prefs
  
   2. manually edit the preparation file
Previously, the only way to specify compilation options was to manually edit the Configuration file. Of course, at that time, we had to walk to school and go through mountains and water. All of this is now in the past.
  
However, if you want to directly use the Configuration file, you have to carefully understand what it actually consists. Most of the options in the Configuration file do not need to be customized, but it is helpful to understand their usefulness.
  
The Configuration file is a brief description of this file. This part is excerpted and its translation is given below:
  
# There are 5 types of lines here:
  
There are five types of code lines:
  
# & Single; comments, distinguished by having a & single; # & single; as the first non-blank character
  
"#" Comment, with the first non-null character "#"
  
#
  
# Makefile options, such as CC = gcc, etc...
  
Make file options, such as CC = gcc, and so on...
  
#
  
# Rules, distinguished by having "Rule" at the front. These are used
  
# Control Configure & single; s behavior as far as how to create Makefile.
  
Rules, the difference between the previous "Rule", used to control Configure behavior and
  
How to create Make files
  
#
  
# Module selection lines, distinguished by having & single; AddModule & single; at the front.
  
# These list the configured modules, in priority order (highest priority
  
# Last). They & single; re down at the bottom.
  
Select a row for the module. The difference between the previous "AddModule" is as follows. These rows are listed in priority order.
  
Has been configured for the module (higher priority is later ). The module is selected at the end of the file.
  
#
  
# Optional module selection lines, distinguished by having '% Module & single;
  
# At the front. These specify a module that is to be compiled in (
  
# Not enabled). The AddModule directive can be used to enable such
  
# Module. By default no such modules are defined.
  
Select a row for the optional Module. The difference between the preceding "% Module" is. Required
  
The compiled module (but not enabled ). The AddModule command can enable this module. Mo
  
This module is not defined.
  
Most users only need to modify the module and select the row. other content is only suitable for users who have a deep understanding of its meaning. At the end of the file, we can find many rows in the following format:
  
AddModule modules/standard/mod_cgi.o
  
It indicates that the specified module (mod_cgi module) should be enabled for Apache compilation ). You can delete a specific module by commenting out the corresponding lines. Otherwise, this module will be enabled if you cancel commenting on the commented rows.
  
We can use the SharedModule command (instead of AddModule) to compile the module into DSO (shared object ):
  
SharedModule modules/standard/mod_vhost_alias.so
  
Note that the mod_so module must be enabled during DSO compilation.
  
Using configure to generate the Configuration. apaci file and check its changes is a good learning method.
  
Once all necessary changes are made in the Configuration file, you only need to run./Configure to start the compilation process.
  
   3. which method is better?
Obviously, both the use of configure and the use of Configure have their own strong supporters, but we can believe that each view has its own faction and history.
  
We recommend that you use both methods. Use configure to generate Configuration files, read these files to understand their functions, and save some of them for later use in the Configure command.

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.