LAMP (3)--apache Configure the domain name jump

Source: Internet
Author: User

★ Demand Realization

The domain name used to build Discuz is www.caoyue111.com

Now we want to implement access to the domain name www.hera111.com when jumping to www.caoyue111.com

★ Configuration Steps

    • We only need to add the following content to the corresponding virtual host

Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

<ifmodule mod_rewrite.c> <== Open rewrite.c module (available apachectl-m to see if there is no module)
Rewriteengine on <== Open
Rewritecond%{http_host} ^www.hera111.com$ <== conditions
Rewriterule ^ (. *) $ http://www.caoyue111.com/$1 [r=301,l] <== results
</IfModule>

    • Use the-t option to check if the configuration is error-free

    • Restart Apache Service

★ I test in the browser found that the contents of the configuration did not take effect, through the inspection found that my system installed in Apache does not have a mod_rewrite module, the following describes the method of installing the Mod_rewrite module for Apache separately

  • First into the Apache source directory

    The Apache source directory i downloaded earlier is stored under/usr/local/src/.


  • Use the Find command to find the Mod_rewrite module in the current directory

    [[email protected] httpd-2.2.16]# find. -name mod_rewrite.c
    ./modules/mappers/mod_rewrite.c

  • Enter the directory containing the Mod_rewrite

    [[Email protected] httpd-2.2.16]# CD./modules/mappers/

  • /usr/local/apache2/bin/apxs-c mod_rewrite.c <== This command must be done in the directory that contains this module

    [Email protected] mappers]#/usr/local/apache2/bin/apxs-c mod_rewrite.c
    /usr/local/apr/build-1/libtool--silent--mode=compile gcc-std=gnu99-prefer-pic-dlinux-d_reentrant-d_gnu_source-d _largefile64_source-g-o2-pthread-i/usr/local/apache2/include-i/usr/local/apr/include/apr-1-I/usr/local/apr/ Include/apr-1-c-o mod_rewrite.lo mod_rewrite.c && Touch Mod_rewrite.slo
    mod_rewrite.c:in function ' lookup_variable ':
    Mod_rewrite.c:1915:error: ' Conn_rec ' has no member named ' Remote_ip '
    Mod_rewrite.c:1954:error: ' Conn_rec ' has no member named ' REMOTE_ADDR '
    mod_rewrite.c:in function ' rewritelock_create ':
    Mod_rewrite.c:2530:warning:implicit declaration of function ' Unixd_set_global_mutex_perms '
    Apxs:Error:Command failed with rc=65536

    Learned that this kind of error message may be related to Libtool version, and then I found that in the directory/usr/local/apache2/build there is no Libtool file, and then I recompile the Apache

  • After recompiling Apache added a lot of static compiled files, but I see/usr/local/apache2/build this time still no Libtool file, continue to do

  • cd/usr/local/src/httpd-2.2.16/modules/mappers/

    /usr/local/apache2/bin/apxs-c mod_rewrite.c

    [Email protected] mappers]#/usr/local/apache2/bin/apxs-c mod_rewrite.c
    /usr/local/apr/build-1/libtool--silent--mode=compile Gcc-prefer-pic-dlinux-d_reentrant-d_gnu_source-d_ Largefile64_source-g-o2-pthread-i/usr/local/apache2/include-i/usr/local/apr/include/apr-1-I/usr/local/apr/ Include/apr-1-c-o mod_rewrite.lo mod_rewrite.c && Touch Mod_rewrite.slo
    /usr/local/apr/build-1/libtool--silent--mode=link Gcc-o mod_rewrite.la-rpath/usr/local/apache2/modules-module- Avoid-version Mod_rewrite.lo

    Seems to have succeeded,

  • chmod 755/usr/local/apache2/modules/mod_rewrite.so Change Permissions

  • See files under/usr/local/apache2/modules It's true that mod_rewrite.so

  • This time I restarted Apache and there was an error message

    Httpd:syntax error on line Of/usr/local/apache2/conf/httpd.conf:module Authn_file_module was built-in and can ' t be lo aded

    The reason for the error is: Although Apache needs to load the Authn_file_module module but now the module is built-in, no need to load module, so the Apaache configuration file does not need to load this module of the line, so the line is commented out.

    View all of Apache's built-in modules,/usr/local/apache2/bin/httpd-l

[[email protected] logs]#/usr/local/apache2/bin/httpd-l
Compiled in modules:
  core.c
 

    • When the prompt is commented out, the error is also indicated

      [[email protected] logs]#/usr/local/apache2/bin/apachectl start
      Httpd:syntax error on line 147 Of/usr/local/apache2/conf/httpd.conf:cannot load/usr/local/apache2/modules/libphp5.so Into server:/usr/local/apache2/modules/libphp5.so:undefined symbol:ap_log_rerror_

      Baidu on the understanding of the solution is related to SELinux, but my current selinux is disabled and try to use this method is not resolved.

      This time I commented out the 147th line and found that the command under Apache2/bin was available.


LAMP (3)--apache Configure the domain name jump

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.