First check to see if the/etc/httpd/conf/extra/httpd-vhosts.conf exists, if you do not need to create one, the contents are as follows:
<virtualhost *:8080>
#绑定的主域
ServerName centos7.xxx.com
#绑定的子域名
Serveralias localhost
#网站主目录
documentroot/var/www/html/
#日志配置
Errorlog/var/log/httpd/error.log
Customlog/var/log/httpd/access.log Common
#ServerSignature OFF
</VirtualHost>
#测试一的配置
<directory "/var/www/html/" >
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Confirm the following configuration entries for the Apache master configuration file (/etc/httpd/conf/httpd.conf):
Include conf/extra/httpd-vhosts.conf
Some words cancel the comment, do not add manually;
Added 127.0.0.1 test.com www.test.com in/etc/hosts
Assigning permissions to a Web directory: Chmod-r-t $path
Detect configuration file correctness: Apachectl configtest
Restart Apache:systemctl Restart httpd
PS: It is important to note that the Apache httpd.conf:
# 该虚拟主机根目录权限相关设置<Directory /> # 允许根目录中的.htaccess生效并覆盖此处设置 AllowOverride All # 允许该目录的所有用户操作权限 Require all granted</Directory>
Centos7 under apache2.4.6 Virtual host configuration