Configure Apache Virtual Host

Source: Internet
Author: User

1. Put the Apache server in the debugging status, so that after changing httpd. conf, it will take effect immediately as long as it is saved.

2. Open the rewrite module.

3. Virtual Path Test

4. Add the default path

5. Conclusion: This article does not study rewriting of. htaccess.

Detailed description:

1. Add this section to around 152 rows (in fact, add it to any ifmoudle module:

# no need to restart server in devoping periodMaxRequestsPerChild 1

 

 

2. uncomment this line:

#LoadModule rewrite_module modules/mod_rewrite.so

 

3.Virtual HostsConfigure nodes to configure virtual hosts,

There are many methods. For example, multiple IP addresses correspond to multiple directories. I used to use this method all the time. Today, this is a failure. This method will be discussed later, today, let's talk about one IP address and multiple domain names, corresponding to multiple directories.

For example, if I access a project under the WWW/pie path in my directory from www.dxpie.com, then I set it like this,

First, since it is an IP address, specify this IP address first,

 

NameVirtualHost *:80

Then, configure document root

<VirtualHost *:80>ServerName www.dxpie.comDocumentRoot "${path}/www/pie"</VirtualHost>

 

Finally, modify the hosts file and direct www.dxpie.com to 127.0.0.1.

 

Now let's test that www.dxpie.com successfully points to my www/pie directory,

But the problem came out. I used localhost and actually directly transferred it to the pie directory. So after step 2, add a few more virtual paths to test it.

 

4. Add the following code under namevirtualhost *: 80:

<VirtualHost *:80>ServerName localhostDocumentRoot "${path}/www"</VirtualHost>

Save and test. Does localhost point to the WWW directory? More than that, all access to port 80 on your local machine will be blocked by this node if it is not matched by other virtual hosts, and access www directly. This is exactly what I want, if you don't think so, change the path.

 

 

5. Do more and make some simple settings for the directory you direct:

<Directory "${path}/www/pie">Options Indexes FollowSymLinksAllowOverride AllOrder deny,allowAllow from all</Directory>

This is copied from the configuration file above. What does it mean? Google can roughly enable rewriting to ensure access.

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.