Apache dynamic compilation and static compilation

Source: Internet
Author: User

Static:
When using./configure compile, if you do not specify a module as dynamic, that is not used: Enable-mods-shared=module or enable-module=shared one of the 2, then all the default module is static.  So what is static? In fact, when compiling all the modules themselves compiled into httpd this file (we start can use this executable file, such as:./HTTPD &), the boot time these modules have been loaded in, that is, can be used, usually:<ifmodule> </ifmodule> to configure. So everyone saw the configuration is <ifmodule module.c>, it is clear that module.c this thing already exists httpd this file.

Dynamic:
When compiling, use enable-module=shared or enable-modules-shared=module to compile dynamically.  So what is dynamic? Static is directly compiled into the httpd, then the dynamic is obviously not compiled into, that is, you start the time will not load this module, but give you a module.so file, you must use LoadModule this syntax to load, this module is valid.

Then the difference comes out: The static module is usually <ifmodule></ifmodule> to be configured, dynamically using Loadmoule to load, and then configure.
As for performance, I didn't pay much attention, the official said static than the dynamic in the performance of about 5% more.
Dynamic relatively convenient point, if you compile, you find that some of the required modules you did not compile (the default number of modules compiled?) You use./configure--help | grep disable view, will let you go to disable that the default will be compiled into, whether the disable what is the use of it? You can dynamically load as long as you have the module.so file.

First look at the option meaning of compiling Apache

For Apache 1.3.x
./configure--prefix=/usr/local/apache \
--ENABLE-MODULE=SO \
--enable-module=most \
--enable-shared=max \
--enable-module=rewrite

For Apache 2.0.x
./configure--prefix=/usr/local/apache2 \
--enable-modules=most \
--enable-mods-shared=all \
--ENABLE-SO \
--enable-rewrite

For Apache 2.2.0
./configure--prefix=/usr/local/apache2 \
--enable-mods-shared=all \
--ENABLE-SO \
--enable-rewrite

Example one: Compiling a apache2.2.8 version
#./configure--prefix=/usr/local/apache--enable-so--enable-mods-shared=most--enable-rewrite--enable-forward
Description
The so module is used to provide DSO-supported Apache core modules.
--ENABLE-SO option: Allow Apache to support DSO mode, note that the Apache2.0 syntax is used here. If your Apache is version 1.3, you should change to--enable-module=so

--enable-mods-shared=most options:
Tells the compiler to dynamically compile all the standard modules into the DSO module.
If you are using Apache1.3, change to--enable-shared=max.

-enable-rewrite option: Support address rewriting function, use 1.3 version of Friends please change it to--enable-module=rewrite
--enable-module=most
With the most you can compile some of the unused modules that are not in the default common modules.
--enable-mods-shared=all means that all modules are loaded dynamically, and if-shared is removed, all modules are loaded statically.

Example two:
Execute./configure--prefix=/server/apache/\
--enable-deflate=shared \
--enable-headers=shared \
--enable-rewrite=shared \
--enable-mods-shared=most

--enable-mods-shared=all means that all modules are loaded dynamically, and if-shared is removed, all modules are loaded statically.
--enable-mods-shared=most is a dynamic compilation of most commonly used modules, of course, you can also choose to load some modules, most of the meaning is only the usual modules, and loaded in the dynamic loading mode. Remember that apache1.xx and Apache2.xx's module compilation is not the same.

Let me say the functions of the above modules:
The Deflate module functions to allow the server to achieve gzip function, can greatly reduce the bandwidth consumption of the server. (Why so, I would like to listen to you, such as a size of 700KB Web page, but through the compression function, we compress to 70KB, then compression to the 70KB to the Web client, actually this is not to reduce the consumption of bandwidth? However, there is a fatal disadvantage, which is to consume the server's CPU, memory resources at the cost.
Note:
In the apache1.xx version, this module is called the Mod_gzip module, which is replaced by the Deflate module in apache2.xx.
Headers function as above, with deflate supporting use.
Rewrite the role of this module is very important, the anti-theft chain almost all rely on it.
In order to have something like this, I would like to load the 3 modules, in fact, there is nothing, then just worry that the 3 modules are not in the "general" category, all manually added. Just add it, there's no problem anyway.
Here, let me explain what it's called dynamic loading and static loading.
Say simple, and explain it in a figurative way.

Like there are two people A and m
A represents the Apache,m representative module
To get a to use M's stuff
One way is to put M's things to a there, a use of the time is ready-made
is called static compilation.

There's another way,
is to tell a, M's address, when a to use M's things, A to find m, and then use
However, one of the problems to be aware of in this way is that M must have an actual address,
Otherwise a will not find m and produce error, I began to mention the Apachectl Startssl produced
The error is this reason, you should compile the SSL.
This method is the Apache dynamic (DSO) compiled

Apache dynamic compilation and static compilation

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.