我的apache无法更改网站根目录,由于某种原因,它指向 /Sites/folder1/folder2 而不是 /Sites 。
我已经配置并更改了我的apache,
<Directory“/Users/saad/Sites”>
以及
DocumentRoot /Users/saad/Sites
重新启动了apachectl,但仍然没有变化。
我的apache无法更改网站根目录,由于某种原因,它指向 /Sites/folder1/folder2 而不是 /Sites 。
我已经配置并更改了我的apache,
<Directory“/Users/saad/Sites”>
以及
DocumentRoot /Users/saad/Sites
重新启动了apachectl,但仍然没有变化。
我也遇到了这个问题,需要更改DocumentRoot并将其指向我自定义的目录,用于保存图像文件。
Berkay是正确的,您需要在apache httpd.config文件上进行一些编辑,但除此之外,您还需要进行一个更改,否则WebSharing将无法再次启动。
使用您喜欢的编辑器打开httpd.config(如果您尚未更改对此文件的权限访问,则可能需要执行此操作)
查找DocumentRoot "/Library/WebServer/Documents"
,并将其更改为 DocumentRoot "/Users/leiwang/Sites"
或任何其他您想要的文件夹。
一个重要的事情是,您需要为指定的文件夹授予读/写权限。
希望能对您有所帮助:)
Require all granted
仅供参考,如果您也遇到此问题,请务必记住这点。<VirtualHost *:80> ServerName localhost DocumentRoot /Library/WebServer/Documents/ </VirtualHost>
添加到 /etc/apache2/extra/httpd-vhosts.conf
文件中。 - Mukesh ChapagainApache有几个文件名相同的文件httpd.conf
"Official"路径在/usr/local/etc/httpd/httpd.conf
中。
DocumentRoot "{您的根路径}"
我去了/etc/apache/users/saad.conf,将虚拟主机以"www.x.dev"的形式添加到我的虚拟主机列表顶部。这暂时解决了问题。希望这可以帮到你。
/private/etc/apache2/
目录下的httpd.conf文件将DocumentRoot定义为/Library/Webserver/Documents
。但是那个目录不起作用!/usr/htdocs
!很奇怪!如果这能帮到其他人,看起来Sierra已经为我创建了一个备份文件,位置在:
/etc/apache2/httpd.conf~previous
我能够将旧的配置文件复制到新文件中,重新启动apache,这样就可以正常工作了。User daemon to User yourMacUsername (you can find that from folder info)
Group daemon to Group staff (this is the default)
403禁止访问
的错误,可以尝试在httpd.config
文件中更新DirectoryIndex
。如果你忘记了文件夹中有.php文件,也会出现这种情况。我的配置文件位于此路径:/private/etc/apache2/httpd.conf
。这解决了我在macOS Monterey上的问题。DirectoryIndex index.html index.php
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
DocumentRoot "/Users/Stephen/Projects/Backend/PHP"
<Directory "/Users/Stephen/Projects/Backend/PHP">
User daemon
Group daemon
</IfModule>
User Stephen
Group daemon
</IfModule>