Why is Mac OS X Lion Apache DocumentRoot /usr/htdocs?

15

5

I am baffled.

I don't see where /usr/htdocs is specified as the DocumentRoot for apache2 on Mac OS X Lion.

It is the default DocumentRoot on a new OSX Lion install.

Can someone point me to where this is specified?

I looked in the entire /etc/apache2 directory and could not find that rule.

vinhboy

Posted 2011-11-18T16:21:59.913

Reputation: 321

nothing in the /etc/apache2/available-sites/* configs? – ragnq – 2011-11-18T16:28:08.343

The default OSX setup does not use the available-sites or enabled-sites structure. – vinhboy – 2011-11-18T16:33:35.363

1It's not. A new OS X Lion installation uses /Library/WebServer/Documents, just like the major releases before Lion, which is also where the button Open Computer Website Folder… in System Preferences » Sharing » Web Sharing points to. Did you install a package manager like Homebrew, Fink, or MacPorts; XAMPP or a similar Apache solution? What is the output of which httpd and ps aux | grep httpd in Terminal? – Daniel Beck – 2011-11-18T17:31:15.310

I did not install any of those package managers. But thanks, I will look down that path. I do see the /Library/WebServer/Documents directive in the httpd.conf file. However, it is obviously being overwritten somewhere else. I tried following all the references to other .conf file, but no luck yet. – vinhboy – 2011-11-18T17:38:52.267

Why not grep for /usr/htdocs on your machine and see where it's overwritten? — (/cc @dan, you didn't get a reply for this) – slhck – 2011-11-18T17:41:02.167

When you write new OSX Lion install, this implies that you didn't restore e.g. your personal data from a Time Machine backup, right? (Thanks @slhck) – Daniel Beck – 2011-11-18T17:46:14.523

Answers

14

When "Web Sharing" is NOT enabled it takes /usr/htdocs as the root. When you enable "Web Sharing" it will take the config file at /etc/apache2/httpd.conf. The directory will be the one specified near the following section on the file.

<IfDefine WEBSHARING_ON>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents"

Also you con use your "Sites" directory at /Users/USERNAME/Sites accessing with localhost/~USERNAME.

timoto

Posted 2011-11-18T16:21:59.913

Reputation: 156

Is that true that some <IfDefine WEBSERVICE > should be commented since its a WEBSERVICE ? – Gucho Ca – 2016-05-26T12:18:54.243

Spot on. Note also the line ServerRoot "/usr" - with Web Sharing OFF and no alternate DocumentRoot specified, it seems the Apache default is to look for htdocs within the defined Server Root. – rymo – 2013-10-24T22:13:29.790

0

Enable your Web Sharing first, Go to the system preferences -> Sharing then enable web sharing. I wrote a post on it.

dimas.priyanto

Posted 2011-11-18T16:21:59.913

Reputation: 9

Could you add more detail? Your post contains more information than what you said here. – Simon Sheehan – 2011-11-27T19:09:14.293

so he wrote a post, go and read it and congifigure your web sharing in lion ))) I did this too, earlier now I have folder "Sites" in my home dir and everything works. – holms – 2011-11-27T19:17:44.930

0

This Q helped me solve identical problem on SnowLeopard today. Beware: it was the httpd.conf in /private/etc/apache2 not in /etc/apache2 (which also exists) that got read and pointed to /Library/WebServer/Documents in my case.

I hope this helps (others too).

P Marecki

Posted 2011-11-18T16:21:59.913

Reputation: 229

The entire /etc folder is a link to /private/etc so the two are one and the same. – Fireandlight27 – 2013-12-05T01:39:55.177

@Fireandlight27 I don't think it was on SL, as I would'n write otherwise. I'm glad they are linked in your case; which OS version? – P Marecki – 2013-12-07T05:59:22.353