方法一:使用httpd-vhosts
进入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 *:81> 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 *:82> 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 *:81> documentroot /home/public/web/host1 servername localhost:81 </virtualhost> <directory /home/public/web/host1> options indexes followsymlinks allowoverride all order allow,deny allow from all </directory> <virtualhost *:82> documentroot /home/public/web/host2 servername localhost:82 </virtualhost> <directory /home/public/web/host2> options indexes followsymlinks allowoverride all order allow,deny allow from all </directory>
apache不同版本 目录权限设置
old使用
order allow,deny allow from all
new使用
require all granted
new example
#add for www listen 91 <virtualhost *:91> documentroot "d:/ide/www" servername localhost:91 </virtualhost> <directory "d:/ide/www"> options indexes followsymlinks allowoverride none require all granted </directory>
到此这篇关于apache httpd配置多个端口的实现方法的文章就介绍到这了,更多相关apache httpd配置多个端口内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论