Thursday, July 26, 2012

OSX Mountain Lion workaround to enable web sharing

I have just upgraded to Mountain Lion. But I feel very disappointed that the web sharing feature is missing. I cannot access my local site, but somehow I still can get the default apache page when accessing http://localhost/.

Here is the workaround that I did to re-enable my own site. To make it safe, make sure to make a copy of /etc/apache2/httpd.conf before modifying anything.

(1) Open terminal, switch to root:
$ sudo su -
(2) Go to /etc/apache2/users/:
$ cd /etc/apache2/users $ ls
(3) I found one file Guest.conf. I copy the file into another file (in this case I am using my own user name: chn.conf), and edit the directory location to my Site location in "/Users/chn/Sites":
$ cp Guest.conf chn.conf $ vi chn.conf
It looks like this after the modification:
<Directory "/Users/chn/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
(4) Let apache load PHP module, by editing the httpd.conf:
$ vi /etc/apache2/httpd.conf
Search for the following line:
#LoadModule php5_module libexec/apache2/
and remove the remark "#" in the beginning of the line so it looks like this:
LoadModule php5_module libexec/apache2/
(5) Restart the apache service by the following command:
$ apachectl restart
Now I can access my own homepage again.

That's all :)

1 comment:

  1. FANTASTIC! This is exactly what I was looking for and is quite simple. No clue why Apple disabled web sharing or didn't provide another solution for local development but the lack of either one is devastating to many, I bet.