当前位置: 代码网 > 服务器>服务器>Linux > apache配置多个http端口的方法

apache配置多个http端口的方法

2025年03月30日 Linux 我要评论
方法一:使用httpd-vhosts(相关推荐:apache)进入apache配置目录,如/usr/local/apache/conf/打开httpd.conf文件配置多个监听窗口81,82serve

apache配置多个http端口的方法

方法一:使用httpd-vhosts

(相关推荐:apache)

进入apache配置目录,如/usr/local/apache/conf/

打开httpd.conf文件

配置多个监听窗口81,82

servername localhost:81  
# listen 80
listen 81  
listen 82
登录后复制

找到#include conf/extra/httpd-vhosts.conf,去掉#号,解除注释

进入/usr/local/apache/conf/extra目录,打开httpd-vhosts.conf文件

配置namevirtualhost *:81

<virtualhost>
    serveradmin host1.example.com
    documentroot "/home/public/web/host1"
    servername localhost:81
    serveralias localhost:81
    errorlog "logs/host1.example.com-error_log"
   #customlog "logs/host1.example.com-access_log common"
</virtualhost>
    
<virtualhost>
    serveradmin host2.example.com
    documentroot "/home/public/web/host2"
    servername localhost:82
    errorlog "logs/host1.example.com-error_log"
   #customlog "logs/host1.example.com-access_log common"
</virtualhost>
登录后复制

方法二:只修改 httpd.conf

进入apache配置目录,如/usr/local/apache/conf/

打开httpd.conf文件

配置多个监听窗口,81,82

listen   81
listen   82
登录后复制

并在文件的最后增加如下内容:

<virtualhost>
documentroot /home/public/web/host1
servername localhost:81
</virtualhost><directory>
 options indexes followsymlinks
allowoverride all
order allow,deny
allow from all
</directory><virtualhost>
documentroot /home/public/web/host2
servername localhost:82
</virtualhost><directory>
 options indexes followsymlinks
allowoverride all
order allow,deny
allow from all
</directory>
登录后复制

apache不同版本 目录权限设置

1、old使用

order allow,deny
allow from all
登录后复制

2、new使用

require all granted
登录后复制

3、new example

#add for www
listen 91
<virtualhost>
documentroot  "d:/ide/www"
servername localhost:91
</virtualhost><directory>
    options indexes followsymlinks
    allowoverride none
    require all granted
</directory>
登录后复制

以上就是apache配置多个http端口的方法的详细内容,更多请关注代码网其它相关文章!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com