Mac 更改Apache檔案系統目錄
阿新 • • 發佈:2018-11-19
環境: 已配置好apache伺服器
參考:
1.mac 中配置apache的DocumentRoot路徑 出現403 Forbidden錯誤
1.在終端中開啟etc/apache2/httpd.conf檔案
$ cd etc/apache2
$ sudo vim httpd.conf
{輸入密碼}
vim編輯
$ i
2.修改DocumentRoot設定
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks Multiviews
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
修改為
DocumentRoot "/Users/apple/Desktop/WebServerDocuments"
<Directory "/Users/apple/Desktop/WebServerDocuments">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks Multiviews
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
鍵盤點選esc回到vim命令狀態,輸入
:wq
進行儲存退出.
3.給新的目錄開放訪問許可權
$ chmod 755 /Users/apple/Desktop/WebServerDocuments
重啟Apache
$ sudo apachectl restart
可在WebServerDocuments中放入.php或.html檔案測試:
完成, 注意如果缺少第三步,訪問頁面資源的時候會報403訪問許可權問題.