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!