我想更改Apache服务器的DocumentRoot,因为我将文件保存在另一个位置。默认文档根目录是
DocumentRoot "/Library/WebServer/Documents"
我把它改为:
DocumentRoot "/Users/blah/Documents/project"
我也改变了:
<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>
到此:
<Directory "/Users/blah/Documents/project">
#
# 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 +ExecCGI
AddHandler cgi-script .cgi .py
MultiviewsMatch Any
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
#
# 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>
然而,当我在终端上运行localhost时,我收到错误: 禁
您无权访问此服务器上的/。 我阅读了许多以前关于类似错误的帖子,并发现有必要更改文件夹的权限。所以我也这样做了。我似乎无法找出问题所在。这是我在项目文件夹中运行ls -la时出现的内容:
total 24
drwxrwxrwx 5 raveen staff 170 Oct 16 13:37 .
drwxr-xr-x 6 raveen staff 204 Oct 15 20:09 ..
-rwxrwxrwx@ 1 raveen staff 438 Oct 16 15:17 index.cgi
-rwxrwxrwx 1 raveen staff 90 Oct 15 22:56 mongo1.php
-rwxrwxrwx@ 1 raveen staff 372 Oct 16 13:37 mongo1.py