首先查看/etc/httpd/conf/extra/httpd-vhosts.conf 是否存在,若是没有须要建立一个,内容以下:
<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>html
确认apache的主配置文件(/etc/httpd/conf/httpd.conf)的下述配置项:
Include conf/extra/httpd-vhosts.conf
有的话取消注释,没有就手动加上;web
PS: 须要注意的是apache的httpd.conf 中:apache
# 该虚拟主机根目录权限相关设置 <Directory /> # 容许根目录中的.htaccess生效并覆盖此处设置 AllowOverride All # 容许该目录的全部用户操做权限 Require all granted </Directory>