首先修改httpd.conf配置文件。javascript
vim conf/httpd.conf
添加:java
Listen 1234
而后把apache
-
# Virtual hosts
-
#Include conf/extra/httpd-vhosts.conf
改为vim
-
# 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:ui
apachectl restart
而后在浏览器访问就能够了,
这里要补充一句, 网上不少资料说conf/extra/httpd-vhosts.conf添加:spa
-
33 <Directory "/xxx/xxx/xxx">
-
35 Order allow,deny
-
36 Allow from all
-
37 </Directory>
这是2.2版本修改配置的方法,2.4版本换套路了,若是这么配置,log日志会报错:rest
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>