'change web root apache mac OS X
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.
Solution 1:[1]
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
Solution 2:[2]
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.
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.
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
Hope it helps:)
Solution 3:[3]
there is a documentroot property in the /etc/apache2/httpd.conf on osx. so we can easily change the path like this;
DocumentRoot "{YOUR_ROOT_PATH}"
Solution 4:[4]
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/
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
For your reference, I just remind you if this ever happens to you.
Solution 5:[5]
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!
Instead,the DocumentRoot which actually works is /usr/htdocs
! Weird!
Solution 6:[6]
Apache has several files with the same name httpd.conf
The "oficial" path is in /usr/local/etc/httpd/httpd.conf
Solution 7:[7]
In case this helps someone else, it looks like Sierra made a backup file for me at:
/etc/apache2/httpd.conf~previous
I was able to copy my old configuration file into the new one, restarted apache and it worked.
Solution 8:[8]
Although i had rights for my folder (and tried the chmod solutions also), it couldnt work for me.
What i found to work is to edit the User and group that runs the htppd conf file:
in httpd.conf file, change:
User daemon to User yourMacUsername (you can find that from folder info)
Group daemon to Group staff (this is the default)
Save and restart apache
Solution 9:[9]
If someone get 403 forbidden
error, try to update the DirectoryIndex
inside the httpd.config
file as well. In case if you forgotten you have .php file in the folder. My config file was in this path /private/etc/apache2/httpd.conf
This solve the issue of my macOs Monterey
DirectoryIndex index.html index.php
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | saadlulu |
Solution 2 | Tine |
Solution 3 | Berkay |
Solution 4 | |
Solution 5 | Tine |
Solution 6 | cabronHp |
Solution 7 | Akexis |
Solution 8 | uzer123 |
Solution 9 | asela daskon |