Apache 多端口多站点配置方法

操作系统Red Hat,apache版本2.4.*
首先修改httpd.conf配置文件。

vim conf/httpd.conf

添加:

Listen 1234

然后把

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

改成

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

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

 24 <VirtualHost *:1234>
 25 DocumentRoot "/xxx/xxx/xxx"
 26 ServerName localhost
 33 <Directory "/xxx/xxx/xxx">
 35     Require all granted
 36 </Directory>
 37 </VirtualHost>

然后重启apache:

apachectl restart

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

 33 <Directory "/xxx/xxx/xxx">
 35       Order allow,deny
 36       Allow from all
 37 </Directory>

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

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

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

 33 <Directory "/xxx/xxx/xxx">
 35     Require all granted
 36 </Directory>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值