Apache Virtual Host configuration (multiple domains access multiple directories)

Source: Internet
Author: User
Tags web hosting
Original: http://dason.blog.51cto.com/658897/505312

Apache Virtual Host configuration (multiple domains access multiple directories)

To facilitate the management of the virtual host, I decided to use one method, that is, to modify the httpd-vhosts.conf file.

The first step is to make the extension file httpd-vhosts.conf effective:
1. Open apache/conf/httpd.conf File
2. Find # Include Conf/extra/httpd-vhosts.conf
3. Remove the previous comment sign #
4. Open apache/conf/extra/httpd-vhosts.conf
5. Add the above multi-port or multi-domain code (this is the case with multi-domain names):
6. Open apache2/conf/extra/httpd-vhost.conf
Add into the bottom:
Example:

 
  
   
      ServerAdmin dason@sina.com (your mailbox)    Documentroot/usr/local/apache2/htdocs/joomla (root directory of this virtual host)    ServerName www.abc.com (here is the domain name)    errorlog/usr/local/apache2/htdocs/abc/error_log (log)    transferlog/usr/local /apache2/htdocs/abc/access_log (log)
 
  
 
  
   
      ServerAdmin dason@sina.com (your email)    documentroot/ Usr/local/apache2/htdocs/bbs (the root directory of this virtual host)    ServerName www.bbs.com (domain name here)    errorlog/usr/local/apache2/ Htdocs/bbs/error_log (log)    Transferlog/usr/local/apache2/htdocs/bbs/access_log (log)
 
  

This example adds a www.abc.com host and a www.bbs.com virtual host.

NOTE: The Apache service must be restarted after the virtual host has been added.

If it is a server, direct access to the domain name will be able to access the corresponding web hosting site.

If you are doing a test environment (I am the test environment), the host file of the real machine can be modified, so that the test domain name and the server (virtual machine) IP Address Association, so that the real machine access to the domain name, the light into the corresponding virtual host site when the success.

The above describes the Apache virtual host configuration (multiple domain names to access multiple directories), including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.