Add Apache rewrite module in Linux

Source: Internet
Author: User
Recently, the project needs to load the rewrite module dynamically in the compiled Apache. As a result, we found a lot of information on the Internet, but it was not very detailed and the format mismatch problem was serious. Therefore, it is necessary to repeat this process. The procedure is as follows:

Job description:
Linux 2.4.21
The decompressed directory of apache_1.3.34.tar.gz is/root/apache_1.3.34"
Apache installation directory/usr/local/Apache is abbreviated as "target directory"

Steps:
1. When installing the rewrite module in Apache, DBM support is required. Otherwise, the rewrite module cannot be compiled. Therefore, you must first install a gdbm
: Ftp://ftp.gnu.org/gnu/gdbm/
Installation steps:
Go to the installation directory,
./Configure
Make
Make install
Make install-compat (the last line also needs to be executed. Otherwise, the ndbm. h header file cannot be compiled)
If you are not sure whether DBM is installed on the server, you can install it. Otherwise, skip this step.

2. Now, in the standard Module Directory of the Apache source code directory (/root/apache_src/src/modules/standard/), use the following command to compile the so file:
/Usr/local/Apache/bin/apxs-C mod_rewrite.c-lgdbm
You can get the mod_rewrite.so file.
Note: "-lgdbm" is used to indicate that the gdbm link should be included when mod_rewrite.c is compiled. In this way, no "dBm fetch" error will be reported when Apache is started in step 1.

3. Now let Apache apxs Add the loadmodule statement to the HTTP. conf configuration file and copy the mod_rewrite.so file to the Apache/libexec directory.
/Usr/local/Apache/bin/apxs-I-a-n rewrite/root/apache_1.3.34/src/modules/standard/mod_rewrite.so
Note: The rewrite parameter in the Command tells the module name in the mod_rewrite.so file of the apxs command. After the command is executed, apxs adds "_ module" to rewrite in loadmodule to name the module. If you encounter errors such as "cannot locate API" when starting Apache, it means that the module name syntax after loadmodule should be changed according to your Apache version.

4. Stop Apache
Apache/bin/apachectl stop

5. Run the configuration file check Command
Apache/bin/apachectl configtest
If syntax OK is displayed, the operation is successful. You can go to step 2. Otherwise, debug as prompted. However, as long as you follow the instructions in this article, no error will occur.

6. Start Apache
Apache/bin/apachectl start

The full text is complete.

Reference original
======================================

One companyLinuxBy default, Apache does not load any modules during installation. Recently, Apache's rewrite module has been used. After a day of hard work, it is finally successful and excited ....
The following key points are listed:
1. Apache requires dBm support when installing the rewrite module, otherwise it cannot be compiled, so first install a gdbm: ftp://ftp.gnu.org/gnu/gdbm/
Installation Steps: Enter the installation directory./configure; Make; make install-compat; otherwise, the ndbm. h header file cannot be compiled.
2. Run the apxs command in the Apache bin directory to install the SDK.
/Var/Apache/bin/apxs-C mod_rewrite.c {
Gcc-dlinux = 22-duse_hsregex-duse_expat-I ../lib/expat-lite-FPIC-dshared_module-I/var/Apache/include-C mod_rewrite.c
Gcc-shared-O mod_rewrite.so mod_rewrite.o-lgdbm
}
/Var/Apache/bin/apxs-I-a-n mod_rewrite mod_rewrite.so

Add loadmodule rewrite_module libexec/mod_rewrite.so to the HTTP. conf configuration file.
Next, use/usr/local/Apache/bin/apachectl.
Stop to stop Apache, and then start again. Please note that you cannot restart Apache with the restart or graceful parameter here. You must stop it first, and then start again, or reboot the machine, otherwise, rewrite will not work.

Bytes -------------------------------------------------------------------------------------------------------------
I tried to include in my Apache web server's configuration The mod_rewrite module, but when I restarted the server, I Have ed an error:

Cannot load/usr/local/Apache/libexec/mod_rewrite.so into server:
/Usr/local/Apache/libexec/mod_rewrite.so: Undefined Symbol: dbm_fetch
The problem, as it turns out, is that mod_rewrite.so is compiled incorrectly. It shoshould be linked with a dBm Library but it isn' t.

If you have an up-to-date set of Apache source files, you can easily solve this problem by manually rerunning the last compilation step of this module, using the correct options. when you execute make mod_rewrite.so in the appropriate directory, it performs this final step:

Gcc-shared-O mod_rewrite.so mod_rewrite.lo
Rerun GCC, this time adding a reference to the GNU gdbm Library:

Gcc-shared-O mod_rewrite.so mod_rewrite.lo-lgdbm
Next, copy the newly created mod_rewrite.so over to/usr/local/Apache/libexec or wherever your Apache module files are located.

In my case, this was all that was needed to solve the problem. Your mileage may vary.

From: http://www.phpchina.cn/bbs/viewthread.php? Tid = 96

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.