How to configure multiple domain names with Apache (absolutely successful!)

Source: Internet
Author: User

Apache installation is done by default does not open the virtual server, if you want to configure the virtual server on the local Apache, similar to the online purchase of virtual hosts, you can follow these steps to configure:

1, modify the Hosts file of this machine, the following example:
127.0.0.1 localhost
127.0.0.1 xlb.com

127.0.0.1 xlb2.com

2, open the Apache installation directory, find httpd.conf files, respectively, remove the following two lines of text before the # number.
LoadModule Vhost_alias_module modules/mod_vhost_alias.so
Remove # means to enable Apache's virtual host feature.
Include conf/extra/httpd-vhosts.conf
Removing this line of # means importing the virtual host configuration from the conf/extra/httpd-vhosts.conf file.

3, open the extra directory of the httpd-vhosts.conf file, the default configuration

<virtualhost *:80>
ServerAdmin Webmaster@dummy-host.localhost
DocumentRoot "/www/docs/dummy-host.localhost"
ServerName Dummy-host.localhost
Serveralias http://www.dummy-host.localhost/
ErrorLog "Logs/dummy-host.localhost-error_log"
Customlog "Logs/dummy-host.localhost-access_log Common"
</VirtualHost>

<virtualhost *:80>
ServerAdmin Webmaster@dummy-host2.localhost
DocumentRoot "/www/docs/dummy-host2.localhost"
ServerName Dummy-host2.localhost
ErrorLog "Logs/dummy-host2.localhost-error_log"
Customlog "Logs/dummy-host2.localhost-access_log Common"
</VirtualHost>

Change to the directory and domain name you want

<virtualhost *:80>
ServerAdmin Webmaster@dummy-host.localhost
DocumentRoot "d:/wamp/www/"
ServerName localhost
Serveralias localhost
ErrorLog "Logs/localhost-error_log"
</VirtualHost>
<virtualhost *:80>
ServerAdmin Webmaster@dummy-host.localhost
DocumentRoot "d:/wamp/www/web/"
ServerName test.com (fill in the main domain name)
Serveralias *.test.com (the server alias here can support universal resolution, that is, all subdomains can be resolved to bind to the virtual host)
ErrorLog "Logs/localhost-error_log"
</VirtualHost>

If you finish, there are 403 errors that are found in the httpd.conf:
<directory/>
Options followsymlinks execcgi Indexes
AllowOverride None
Order Deny,allow
Deny from all
Satisfy All
</Directory>

Change to
<directory/>
Options followsymlinks execcgi Indexes
AllowOverride None
# Order Deny,allow
# Deny from all
# Satisfy All
</Directory>

After the configuration is finished, you can enter xlb.com in the browser to access the site under your set directory.

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.