首先查看/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>