在 Mac OS X 10.9 (Mavericks) 中启动内置 Apache 服务器

Bag*_*yer 6 apache-http-server webserver osx-mavericks macos

我想在运行 OS X (10.9) Mavericks 的 Mac 上启动我的 apache 服务器。这是我所做的:

  1. 转到终端
  2. 须藤 apachectl 开始
  3. 服务器启动没有问题。但是当我尝试在 Web 浏览器中打开 localhost 时遇到以下问题:

您无权访问 / 在此服务器上。

这是我的 /etc/apache2 中的 httpd.conf 文件:(我在这里没有更改任何内容)

DocumentRoot "/Library/WebServer/Documents"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all </Directory>

<Directory "/Library/WebServer/Documents">

    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议可能是什么原因?谢谢

小智 10

我遇到了同样的问题。经过一番思考,我发现主要问题是 Apache 以用户_www运行,而您的文件可能在您自己的用户下。在终端 (ls -l) 中列出 webroot 文件夹的内容以查看用户及其组。

我发现此链接提供了“更好的解决方案”,而不是“更改所有者”“更改权限”http : //francoisdeschenes.com/2013/02/26/enable-write-permissions-for-apache-built -into-mac-os-x

简而言之,执行此操作(将 <dir> 替换为您的文件夹名称):

sudo chmod -R +a '_www allow read,write,delete,add_file,add_subdirectory,file_inherit,directory_inherit' <dir>
Run Code Online (Sandbox Code Playgroud)

当然,所有的荣耀都归弗朗索瓦所有。