Modify DocumentRoot in Apache (Mac)
After you've installed Apache with Homebrew on macOS, you might want to change the
Here are the steps to follow to change
DocumentRoot which points to the directory where your website resources reside (e.g. HTML, CSS, images). By default, DocumentRoot is located in /usr/local/var/www 1.
Here are the steps to follow to change
DocumentRoot to map to a custom directory path:- Place your website folder to the desired place.
For example:/usr/local/var/www/my_website - Open the file
/usr/local/etc/httpd/httpd.confwith your favorite editor, search forDocumentRoot, and modify the following line by substituting your directory path within the double quotes:Also change the next line: - Restart your Apache server (if you want Apache to restart at login):
- Test the changes to
DocumentRootby openinghttp://localhostwith your browser. You should see your local site's homepage.
sudo, I have problems accessing some pages of my local site with the following error message shown (on Chrome):
"This site can’t be reached:
I tried to change the ERR_CONNECTION_REFUSED" DocumentRoot directory owner to _www, and tried to set the directory permission to 777. But to no avail, I still had the same problem where some pages could be accessed and others not. It's only by restarting Apache with sudo that I was able to resolve this connection issue:Notes
1. ^/Library/WebServer/Documents is also another default directory location used by Apache on macOS, see reference.
Comments
Post a Comment