天天看點

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.     # AllowOverride controls what directives may be placed in .htaccess files.  
  19.     # It can be "All", "None", or any combination of the keywords:  
  20.     #   AllowOverride FileInfo AuthConfig Limit  
  21.     #  
  22.     AllowOverride None  
  23.     #  
  24.     # Controls who can get stuff from this server.  
  25.     #  
  26.     Require all granted  
  27. </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.     # apache 2.4  
  9.     Require local  
  10. </Directory>  

Apache運作指令:

sudo apachectl start  //開始

sudo apachectl restart  //重新開機

sudo apachectl stop  //停止