apache2.4配置

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

vim conf/httpd.conf

添加:java

Listen 1234

而後把apache

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

改爲vim

  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:ui

apachectl restart

而後在瀏覽器訪問就能夠了,
這裏要補充一句, 網上不少資料說conf/extra/httpd-vhosts.conf添加:spa

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

這是2.2版本修改配置的方法,2.4版本換套路了,若是這麼配置,log日誌會報錯:rest

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>
相關文章
相關標籤/搜索