分享web开发知识

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

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

apache2.4配置

发布时间:2023-09-06 02:19责任编辑:蔡小小关键词:apache配置

首先修改httpd.conf配置文件。

vim conf/httpd.conf

添加:

Listen 1234

然后把

  1.  
    # Virtual hosts
  2.  
    #Include conf/extra/httpd-vhosts.conf

改成

  1.  
    # Virtual hosts
  2.  
    Include conf/extra/httpd-vhosts.conf

就是使用虚拟配置,然后去编辑conf/extra/httpd-vhosts.conf,添加:

  1.  
    24 <VirtualHost *:1234>
  2.  
    25 DocumentRoot "/xxx/xxx/xxx"
  3.  
    26 ServerName localhost
  4.  
    33 <Directory "/xxx/xxx/xxx">
  5.  
    35 Require all granted
  6.  
    36 </Directory>
  7.  
    37 </VirtualHost>

然后重启apache:

apachectl restart

然后在浏览器访问就可以了,
这里要补充一句, 网上很多资料说conf/extra/httpd-vhosts.conf添加:

  1.  
    33 <Directory "/xxx/xxx/xxx">
  2.  
    35 ??????Order allow,deny
  3.  
    36 ??????Allow from all
  4.  
    37 </Directory>

这是2.2版本修改配置的方法,2.4版本换套路了,如果这么配置,log日志会报错:

client denied by server configuration: /xxx/xxx/xxx, referer: http://xxx/xxx/xxx

所以,对于2.4版本的apache,正确的配置方法是:

 
  1.  
    33 <Directory "/xxx/xxx/xxx">
  2.  
    35 Require all granted
  3.  
    36 </Directory>

apache2.4配置

原文地址:https://www.cnblogs.com/weizaiyes/p/9846697.html

知识推荐

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