macos 更改 web root apache mac OS X
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8851544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
change web root apache mac OS X
提问by saadlulu
I cant change my web root in apache, for some reason it points to /Sites/folder1/folder2 instead of it pointing to /Sites.
I configured and change my apache
<Directory "/Users/saad/Sites">
and
DocumentRoot /Users/saad/Sites
restarted my apachectl and still nothing.
我无法在 apache 中更改我的 web 根目录,出于某种原因,它指向 /Sites/folder1/folder2 而不是指向 /Sites。我配置并更改了我的 apache
<Directory "/Users/saad/Sites">
并
DocumentRoot /Users/saad/Sites
重新启动了我的 apachectl,但仍然没有。
采纳答案by saadlulu
I went to /etc/apache/users/saad.conf and added the virtual host in this form "www.x.dev" to the top of my virtual hosts list. this temporarily fixed the problem. hope this helps
我转到 /etc/apache/users/saad.conf 并将以“www.x.dev”这种形式的虚拟主机添加到我的虚拟主机列表的顶部。这暂时解决了这个问题。希望这可以帮助
回答by David_Wang
I just meet this problem, too. I need to change the DocumentRoot and point it to my customised directory, which used for saving image files.
我也刚遇到这个问题。我需要更改 DocumentRoot 并将其指向我用于保存图像文件的自定义目录。
Berkay is right, you need edit a bit on your apache httpd.config file, but besides that, you need to do one more change, otherwise the WebSharing won't be able to turn on again.
Berkay 是对的,您需要对您的 apache httpd.config 文件进行一些编辑,但除此之外,您还需要再做一次更改,否则 WebSharing 将无法再次打开。
Open your httpd.config by your favorite editor (Probably need to do this if you haven't change the permission access to this file)
- sudo chmod 666 httpd.conf
- Open httpd.config, and start editing.
- sudo chmod 644 httpd.conf, when it's finished, proceed to step 2 (change it back to original permisson access)
Find
DocumentRoot "/Library/WebServer/Documents"
, and change it toDocumentRoot "/Users/leiwang/Sites"
or any other folders you want to.One important thing is, you need to give the Read/Write permission to the folder you specified.
- sudo chmod -R 747 foldername
用你最喜欢的编辑器打开你的 httpd.config(如果你没有改变这个文件的权限,可能需要这样做)
- 须藤 chmod 666 httpd.conf
- 打开httpd.config,开始编辑。
- sudo chmod 644 httpd.conf,完成后,继续第2步(改回原来的permisson access)
查找
DocumentRoot "/Library/WebServer/Documents"
,并将其更改为DocumentRoot "/Users/leiwang/Sites"
您想要的或任何其他文件夹。一件重要的事情是,您需要为您指定的文件夹授予读/写权限。
- 须藤 chmod -R 747 文件夹名
Hope it helps:)
希望能帮助到你:)
回答by us_david
I ran into this problem: Once you change the root of web server to somewhere other than the default (/Library/WebServer/Documents), you need setup virtual host, otherwise, localhost will not work, and you will get:403 Forbidden
error
You can refer to this link for details on how to set it up:
http://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/
我遇到了这个问题:一旦你将web服务器的根目录更改为默认值(/Library/WebServer/Documents)以外的其他地方,你需要设置虚拟主机,否则,localhost将无法工作,你会得到:403 Forbidden
错误
你可以有关如何设置的详细信息,请参阅此链接:http:
//coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/
Also make sure the following line is in the configuration file for the web directory if your Max is running OS X 10.10:Require all granted
如果您的 Max 运行的是 OS X 10.10,还要确保 Web 目录的配置文件中包含以下行:Require all granted
For your reference, I just remind you if this ever happens to you.
供您参考,如果您遇到这种情况,我只是提醒您。
回答by Berkay
there is a documentroot property in the /etc/apache2/httpd.conf on osx. so we can easily change the path like this;
osx 上的 /etc/apache2/httpd.conf 中有一个 documentroot 属性。所以我们可以很容易地改变这样的路径;
DocumentRoot "{YOUR_ROOT_PATH}"
文档根目录“{YOUR_ROOT_PATH}”
回答by cabronHp
Apache has several files with the same name httpd.conf
Apache 有多个同名文件 httpd.conf
The "oficial" path is in /usr/local/etc/httpd/httpd.conf
“官方”路径在 /usr/local/etc/httpd/httpd.conf
回答by shengfengli
I came across the similar question as you, the httpd.conf under /private/etc/apache2/
defines the DocumentRoot as /Library/Webserver/Documents
. But that directory doesn't work!
我遇到了和你类似的问题,httpd.conf 下/private/etc/apache2/
的 DocumentRoot 定义为/Library/Webserver/Documents
. 但是那个目录不起作用!
Instead,the DocumentRoot which actually works is /usr/htdocs
! Weird!
相反,实际工作的 DocumentRoot 是/usr/htdocs
! 奇怪的!
回答by Akexis
In case this helps someone else, it looks like Sierra made a backup file for me at:
如果这对其他人有帮助,Sierra 似乎在以下位置为我制作了一个备份文件:
/etc/apache2/httpd.conf~previous
/etc/apache2/httpd.conf~上一个
I was able to copy my old configuration file into the new one, restarted apache and it worked.
我能够将旧的配置文件复制到新的配置文件中,重新启动 apache 并且它工作正常。