zi663227 发表于 2018-11-18 06:56:12

centos7下apache2.4.6虚拟主机配置


[*]  首先查看/etc/httpd/conf/extra/httpd-vhosts.conf 是否存在,如果没有需要创建一个,内容如下:

#绑定的主域
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

#测试一的配置

Options FollowSymLinks
AllowOverride All
Require all granted


[*]  确认apache的主配置文件(/etc/httpd/conf/httpd.conf)的下述配置项:
Include conf/extra/httpd-vhosts.conf
有的话取消注释,没有就手动加上;

[*]在/etc/hosts 新增 127.0.0.1 test.com www.test.com
[*]给web目录赋权限:chmod -R-t$path
[*]检测配置文件正确性:apachectl configtest
[*]重启apache:systemctl restart httpd
  PS: 需要注意的是apache的httpd.conf 中:

# 该虚拟主机根目录权限相关设置

# 允许根目录中的.htaccess生效并覆盖此处设置
AllowOverride All
# 允许该目录的所有用户操作权限
Require all granted



页: [1]
查看完整版本: centos7下apache2.4.6虚拟主机配置