PHP Apache Configuration Virtual Host

Source: Internet
Author: User
1. Locate the httpd.conf file in the Apache \conf directory, open it, and locate the following two lines:

# Virtual Hosts

#Include conf/extra/httpd-vhosts.conf

Remove the # from the front of him and modify it as follows:

# Virtual Hosts

Include conf/extra/httpd-vhosts.conf

It means to enable the setting of the virtual host file httpd-vhosts.conf, the virtual host settings are set in this file, do not have to change the httpd.conf, so it is more clear.



2. Locate the httpd-vhost.conf file in the Apache \conf\extra directory.

When you open it, it already contains something like the following:

? virtual Host Configuration Start

ServerAdmin Webmaster@dummy-host.localhost

DocumentRoot "E:/wamp/www/ecshop"//Website root path-The directory of the virtual host, that is, the root directory of the domain name

ServerName "www.baidu.com"//Virtual Host domain name-the domain name you want

Serveralias Www.dummy-host.localhost

Errorlog "Logs/dummy-host.localhost-error.log"

Customlog "Logs/dummy-host.localhost-access.log" common


Also add the following before each virtual host configuration starts:

This is your virtual host's authorized directory generally with DocumentRoot ""? The directory of the virtual host, which is the same as the root directory of the domain name.

Options Indexes FollowSymLinks includes execcgi

AllowOverride All

Order Allow,deny

Allow from all

Allow from all-the directory defined above can be accessed only if allowed, otherwise the 503 error will be displayed when IE or Firefox is accessed, which is forbidden. This is the default Apache setting, and the last line is this

Deny from all means deny access to the root directory, and others cannot access your site.

So if you want other users to have access to your project, you have to change the

Allow from all

3. Locate the Hosts file in the C:\WINDOWS\system32\drivers\etc directory

Plus one sentence below.

127.0.0.1 www.baidu.com? This is your domain name, how many virtual hosts you want to set, and how many rows of such records will be added.

=========================================================================================================
Example
 
  
   
  Options Indexes followsymlinks includes execcgiallowoverride allorder allow,denyallow
 
  
 from all 
  
   
  ServerAdmin webmaster@dummy-host2.localhostdocumentroot E:\wamp\www\ecshopServerName Www.test.comErrorLog Logs/dummy-host2.localhost-error_logcustomlog Logs/dummy-host2.localhost-access_log Common
 
  
  • 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.