mac修改apache中httpd.conf,修改默認訪問路徑

1. 打開修改/etc/apache2/httpd.conf內容, 查找如下:

[html] view plain copy
  1. DocumentRoot "/Library/WebServer/Documents"  
  2. <Directory "/Library/WebServer/Documents">  
  3.     #  
  4.     # Possible values for the Options directive are "None", "All",  
  5.     # or any combination of:  
  6.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews  
  7.     #  
  8.     # Note that "MultiViews" must be named *explicitly* --- "Options All"  
  9.     # doesn't give it to you.  
  10.     #  
  11.     # The Options directive is both complicated and important.  Please see  
  12.     # http://httpd.apache.org/docs/2.4/mod/core.html#options  
  13.     # for more information.  
  14.     #  
  15.     Options FollowSymLinks Multiviews  
  16.     MultiviewsMatch Any  
  17.   
  18.     #  
  19.     # AllowOverride controls what directives may be placed in .htaccess files.  
  20.     # It can be "All", "None", or any combination of the keywords:  
  21.     #   AllowOverride FileInfo AuthConfig Limit  
  22.     #  
  23.     AllowOverride None  
  24.   
  25.     #  
  26.     # Controls who can get stuff from this server.  
  27.     #  
  28.     Require all granted  
  29. </Directory>  
原來Apache根目錄是/Library/WebServer/Documents, 現改爲/Users/username/phpSites, 如下:

[html] view plain copy
  1. DocumentRoot /Users/username/phpSites  
  2. <Directory /Users/username/phpSites>  
  3.     Options Indexes MultiViews  
  4.     # apache 2.2  
  5.     # AllowOverride All  
  6.     # Order allow,deny  
  7.     # Allow from 127.0.0.1  
  8.   
  9.     # apache 2.4  
  10.     Require local  
  11. </Directory>  

Apache運行命令:

sudo apachectl start  //開始
sudo apachectl restart  //重啓
sudo apachectl stop  //停止

發佈了52 篇原創文章 · 獲贊 22 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章