Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Problems and Solutions of Virtual Host configuration in apache-2.4.12

Shulou Source: shulou.com Published: 2022-06-03 06:24:16 11月23日 Update

Apache-2.4.12 multi-virtual host configuration based on domain name access

Original configuration:

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

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

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

Can you see what's wrong with the above multi-virtual host configuration based on domain name access? At first glance, there is no problem, but when configured in this way under apache-2.4.12, there is a 403 error in access and no permission to access it. According to the prompt, there is no problem with the permission of the directory and file, and there is no obvious error in viewing the program error log and system log. Then calm down and think carefully that there is no problem with the directory and file permissions. Then the rest is the site directory access permission, so add this paragraph before the virtual host configuration in the virtual host configuration file:

Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride All

Require all granted

Further modifications to the virtual host configuration file are as follows:

Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride All

Require all granted

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

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

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

After the above modifications, restart the apache service, and now you can access it normally. Ha ha, the big function is complete!

Tags: Configuration host virtual host problems files permissions directories errors domain names logs is original obvious great work that is programs sites systems good thoughts tips Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB OPPO Reno Redmi Huawei