分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

centos7下apache2.4.6虚拟主机配置

发布时间:2023-09-06 01:42责任编辑:熊小新关键词:apache配置虚拟主机
  • 首先查看/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>

  • 确认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 中:

    # 该虚拟主机根目录权限相关设置<Directory /> ???# 允许根目录中的.htaccess生效并覆盖此处设置 ???AllowOverride All ???# 允许该目录的所有用户操作权限 ???Require all granted</Directory>

    centos7下apache2.4.6虚拟主机配置

    原文地址:http://blog.51cto.com/leonsecurity/2071214

    知识推荐

    我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
    icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved