Configuration of multiple virtual hosts accessed by domain name in apache-2.4.12

Source: Internet
Author: User

Configuration of multiple virtual hosts accessed by domain name in apache-2.4.12

Configuration of multiple virtual hosts accessed by domain name in apache-2.4.12


Original Configuration:

<VirtualHost *: 80>

ServerAdmin kk@etiantian.org

DocumentRoot "/data/cms"

ServerName www.etiantian.org

ServerAlias etiantian.org

ErrorLog "logs/www.etiantian.org-error_log"

CustomLog "logs/www.etiantian.org-access_log" common

</VirtualHost>


<VirtualHost *: 80>

ServerAdmin kk@etiantian.org

DocumentRoot "/data/bbs"

ServerName bbs.etiantian.org

ErrorLog "logs/bbs.etiantian.org-error_log"

CustomLog "logs/bbs.etiantian.org-access_log" common

</VirtualHost>


<VirtualHost *: 80>

ServerAdmin kk@etiantian.org

DocumentRoot "/data/blog"

ServerName blog.etiantian.org

ErrorLog "logs/blog.etiantian.org-error_log"

CustomLog "logs/blog.etiantian.org-access_log" common

</VirtualHost>

Can you see the error in the above multi-Virtual Host Configuration Based on Domain Name access? At first glance, there is no problem, but after this configuration is completed in apache-2.4.12, a 403 error occurs during access and no permission for access. Check the Directory and file permissions according to the prompts, and there is no problem. Check the program error log and system log without any obvious errors. Then, calm down and think about it, there is no problem with the Directory and file permissions, and the rest is the site directory access permissions. Therefore, before configuring the virtual host in the virtual host configuration file, add the following section:


<Directory "virtual host site Directory">

Options Indexes FollowSymLinks between des ExecCGI

AllowOverride All

Require all granted

</Directory>


Modify the VM configuration file as follows:



<Directory "/data">

Options Indexes FollowSymLinks between des ExecCGI

AllowOverride All

Require all granted

</Directory>

<VirtualHost *: 80>

ServerAdmin kk@etiantian.com

DocumentRoot "/data/cms"

ServerName www.etiantian.org

ServerAlias etiantian.org

ErrorLog "logs/www.etiantian.org-error_log"

CustomLog "logs/www.etiantian.org-access_log" common

</VirtualHost>



<VirtualHost *: 80>

ServerAdmin kk@etiantian.com

DocumentRoot "/data/bbs"

ServerName bbs.etiantian.org

ErrorLog "logs/bbs.etiantian.org-error_log"

CustomLog "logs/bbs.etiantian.org-access_log" common

</VirtualHost>



<VirtualHost *: 80>

ServerAdmin kk@etiantian.com

DocumentRoot "/data/blog"

ServerName blog.etiantian.org

ErrorLog "logs/blog.etiantian.org-error_log"

CustomLog "logs/blog.etiantian.org-access_log" common

</VirtualHost>


After the above modification, restart the apache service and now it can be accessed normally!

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.