Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 更改Yosemite Apache 2.4的本地主机目录_Macos_Apache_Apache2_Osx Yosemite_Apache2.4 - Fatal编程技术网

Macos 更改Yosemite Apache 2.4的本地主机目录

Macos 更改Yosemite Apache 2.4的本地主机目录,macos,apache,apache2,osx-yosemite,apache2.4,Macos,Apache,Apache2,Osx Yosemite,Apache2.4,我已经干净地安装了MacOSXYosemite,但是我不能像在旧OSX版本上一样配置Apache2.4 我想做的是:将“localhost”目录设置为“/Users/username/Public/”。 但是,我尝试的一切都不起作用,我总是得到一个“禁止,无法访问/”或者我得到默认的“它起作用!”页面 如何简单地重新启动我的本地主机 Thx 编辑(感谢克里斯特·安德森的回答) 适用于Mac OSX 10.10 Yosemite 我还发布了为了保持运行而必须做的更改 在“/etc/apache2/

我已经干净地安装了MacOSXYosemite,但是我不能像在旧OSX版本上一样配置Apache2.4

我想做的是:将“localhost”目录设置为“/Users/username/Public/”。 但是,我尝试的一切都不起作用,我总是得到一个“禁止,无法访问/”或者我得到默认的“它起作用!”页面

如何简单地重新启动我的本地主机

Thx

编辑(感谢克里斯特·安德森的回答)

适用于Mac OSX 10.10 Yosemite

我还发布了为了保持运行而必须做的更改

在“/etc/apache2/users/”中,我创建了一个以我的用户名命名的文件,如“myUsername.conf”

您可以通过在终端中键入“id”来获取用户名。您应该在“uid=501(myUsername)”中找到您的用户名

在这个新的“myUsername.conf”文件中,只需复制以下内容:

<Directory "/Users/myUsername/Sites/">
    AllowOverride All
    Options Indexes MultiViews
    Options +FollowSymLinks
    Require all granted
</Directory>
第236行,将“DocumentRoot”目录更改为您想要的任何目录。 第250行,将“选项”设置为“选项”选项索引跟随“链接多视图”。 第258行,将“AllowOverride None”设置为“AllowOverride All”。 第263行,将“要求全部拒绝”设置为“要求全部授予”

在终端中,键入“sudo apachectl restart”重新启动apache


它适合我在Mac OS X 10.10 Yosemite clean install上使用。

我刚刚安装了Yosemite,并且我成功地更改了
文档root
,没有任何问题。首先,我修改了
/private/etc/apache2/httpd.conf中的以下行:

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews

AllowOverride None
</Directory>
然后可以在
httpd vhosts.conf
文件中添加以下内容:

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
   ServerAdmin webmaster@example.local
   DocumentRoot "/Library/WebServer/Documents"
   ServerName example.local
   ErrorLog "/private/var/log/apache2/example.local-error_log"
   CustomLog "/private/var/log/apache2/example.local-access_log" common

   <Directory "/Library/WebServer/Documents">
     Options Indexes FollowSymLinks Multiviews
     AllowOverride All
     Order allow,deny
     Allow from all
   </Directory>
</VirtualHost>

在El Capitan上,应使用“-k”标志重新启动apache:
sudo apachectl-k restart

可能重复的否,它不是重复的。虽然我很感激已经回答了这个问题,但未来的读者可能会想看看。它也适用于OS X El Capitan和Sierra以及High Sierra nowNice!它也适用于我。我在“服务器配置”方面很差。非常感谢,我还回答了我的问题,发布了我的配置(我从其他来源添加了一些更改)。另外:您知道如何将localhost设置为root吗?”/“仅适用于127.0.0.1,从外部请求的127.0.0.1已重定向到另一个文件夹?@Jordan-我可能可以提供帮助,但是,由于这似乎是一个不同的问题,我认为您应该首先创建一个新的问题,并且您还应该尝试添加关于您正在尝试执行的操作的更清晰的信息。在Apache 2.4下,这不再适用于我。出于某种原因,它似乎并不尊重DocumentRoot。@Shavais-您重新启动了apache吗?你确定你正在编辑正确的配置文件吗?嗯,好吧,别提我的评论。它正在工作。我注意到访问日志显示index.html为304,因此我转储了浏览器缓存-我正在查看index.html的缓存版本。我的配置的上一次迭代为我的其他文件提供了404,因此我假设问题出在DocumentRoot上,但显然不是这样,而当前迭代(包括权限更改等)已修复了该问题。这解决了我的根目录不更新的问题:)
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
   ServerAdmin webmaster@example.local
   DocumentRoot "/Library/WebServer/Documents"
   ServerName example.local
   ErrorLog "/private/var/log/apache2/example.local-error_log"
   CustomLog "/private/var/log/apache2/example.local-access_log" common

   <Directory "/Library/WebServer/Documents">
     Options Indexes FollowSymLinks Multiviews
     AllowOverride All
     Order allow,deny
     Allow from all
   </Directory>
</VirtualHost>
sudo apachectl restart