Topic: https://brettterpstra.com/2012/07/28/fixing-virtual-hosts-and-web-sharing-in-mountain-lion/
hide preview

What's next? verify your email address for reply notifications!

Rob George 12y, 77d ago

This command autostarts apache : sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false

From this article: http://reviews.cnet.com/830...

hide preview

What's next? verify your email address for reply notifications!

phil 12y, 93d ago

thx man, you really saved me a lot of time!

hide preview

What's next? verify your email address for reply notifications!

joey 12y, 137d ago

To have the webserver running after a reboot just change the value from disabled to enabled in : /System/Library/LaunchDaemons/org.apache.httpd.plist

and to launch right away:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

hide preview

What's next? verify your email address for reply notifications!

Marco Berrocal 12y, 170d ago

Absolute bollocks that they kill it like that without notifying. Lately, I don't know, think Apple forgets who their prime users were, the ones who supported them through good and bad,

hide preview

What's next? verify your email address for reply notifications!

Brad 12y, 176d ago

Dan,

Well, mine looks about the same (except I have 'AllowOverride None'), and it works. Don't know quite where to look next.

hide preview

What's next? verify your email address for reply notifications!

Dan O'Reilly 12y, 178d ago

I had a test Apache server installed with PHP and MySql on OS X Lion, which was working fine, and recently upgraded to OS X Mountain Lion. The Apache server was not currently running when I upgraded. I was able to get Apache running again using the type of suggestions posted on this blog. I can access PHP from my "~username/Sites/" folder by entering "http://localhost/~username" with no problem. However, when I attempt to access "localhost" using "http://localhost" I receive the message "Forbidden You don't have permission to access / on this server." I am also having problems with my phpMyAdmin and I think it is related to this, as there is a similar error message. Does anyone have any suggestions why I am getting the permission access restriction message at 'root' but not at the Sites folder?

remark link
hide preview

What's next? verify your email address for reply notifications!

Brad 12y, 177d ago

Dan:

Do you have anything specified as 'DocumentRoot' in /etc/apache2/httpd.conf? Or a '' entry with Indexes turned on?

Of course, both of those need to be uncommented.

-Brad

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Brad 12y, 177d ago

Hm HTML ate it. I was asking about an entry, surrounded by angle brackets, clled 'Directory "/Library/WebServer/Documents"'.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Dan O'Reilly 12y, 177d ago

In httpd.conf I have the following:

DocumentRoot "/Library/WebServer/Documents"

and


#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named explicitly --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/doc...
# for more information.
#
Options Indexes FollowSymLinks MultiViews

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

remark link parent

load more (2 remarks)
hide preview

What's next? verify your email address for reply notifications!

Brett 12y, 177d ago

It's Markdown, folks. Indent your code blocks 4+ spaces and it will leave the formatting intact.

hide preview

What's next? verify your email address for reply notifications!

Dan O'Reilly 12y, 177d ago

Hmm ... repeating because of HTML:

In httpd.conf I have the following:

DocumentRoot "/Library/WebServer/Documents"

and

&#060Directory "/Library/WebServer/Documents"&#062
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named explicitly --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/doc...
# for more information.
#
Options Indexes FollowSymLinks MultiViews

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

&#060/Directory&#062

hide preview

What's next? verify your email address for reply notifications!

Brad 12y, 221d ago

I'm just overly cautious, I guess. And, I'm primarily a Linux admin, where I always specify on-boot daemon launches in sysV init scripts. Having less familiarity with launchd, I just felt safer specifying the apachectl startup directly. Plus, what if somebody had stopped apachectl manually before the system restart? This verifies that it'll always start up in the desired state, which again hearkens back to my Linux heritage.

hide preview

What's next? verify your email address for reply notifications!

Brad 12y, 222d ago

Lri is correct, above, about the launchctl command. However, that's actually exactly what the 'apachectl' script does. So, in any case, if you've started Apache with apachectl or with launchctl manually, it'll still be working through a clean reboot.

But what if it reboots uncleanly? In that case, it's better to use the existing plist than to build your own. To set this up, I added the following line to root's crontab (with sudo crontab -e):
@reboot /usr/sbin/apachectl restart

Now, Apache is always started on boot, and I didn't have to hack up my own plist. I use 'restart' because, if it's started already (by the persistence of the launchctl daemon), a 'start' command will cause a warning that httpd is already running. But 'restart' works without complaining whether Apache is already running or not.

remark link
hide preview

What's next? verify your email address for reply notifications!

Lri 12y, 221d ago

I should've read the man page. sudo apachectl start also modifies /private/var/db/launchd.db/com.apple.launchd/overrides.plist, which overrides the Disabled key in /System/Library/LaunchDaemons/org.apache.httpd.plist, just like launchctl load -w.

Why would you need to run apachectl restart after an unclean reboot? Or are there some cases where the launchd service doesn't keep httpd running?

hide preview

What's next? verify your email address for reply notifications!

Phillip Molaro 12y, 223d ago

After following your steps my virtual hosts still didn't come back up. I checked my apache file syntax and discovered the issue. It seems that before there was an /etc/httpd/ssl.key path. Now it looks like httpd has been removed, so the path is now just etc/ssl.key.

A lot of my sites run under a local SSL cert i setup, so when those couldn't be found, apache failed to load correctly.

To recap, if your hosts don't come up, issue this command:
sudo apachectl -t

You should see an error something like this:
Syntax error on line 99 of /private/etc/apache2/extra/httpd-ssl.conf:
SSLCertificateFile: file '/etc/httpd/ssl.key/my-custom-site.crt' does not exist or is empty

Open the file with the error (/private/etc/apache2/extra/httpd-ssl.conf) and modify the path by removing the "httpd/" from the path. There will most likely be two places where you will need to change that. I had several and just kept repeating the steps until all my ssl locations were updated. Hope this helps others.

hide preview

What's next? verify your email address for reply notifications!

Kjell 12y, 225d ago

Maybe helpful too:

check in httpd.conf if you are not by chance including both the httpd-vhosts.conf located in
/private/etc/apache2/other AND
/private/etc/apache2/extra

For me this was the big mistake.

Be sure to check the output of both apache:
apachectl -t AND
apachectl -S

The first keep on warning me about a fully qualified domain name, but things are working now...

hide preview

What's next? verify your email address for reply notifications!

Lri 12y, 229d ago

I'm still not sure, but according to comments on other sites it would seem that the launchd plist that starts Apache is still there on clean installations of 10.8, and you don't have to make your own one.

launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist would start Apache and enable the launchd service that starts it automatically after logging out and back in.

To make http://localhost/~username/ work, you have to create /etc/apache2/users/username.conf and add a <Directory> directive like this:

<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
remark link
hide preview

What's next? verify your email address for reply notifications!

yxvm 12y, 227d ago

Thank you!!!!!!!!!!!!!

hide preview

What's next? verify your email address for reply notifications!

ralph elliott 12y, 233d ago

I did a test install of ML just to check this out after reading other comments on the web. Things turned out to be better than I'd been led to believe: "sudo apachectl start" told me it was already running, and when I directed Safari to http://localhost/, indeed it was running. I guess this was because I installed ML on top of a Lion system which had Web Sharing enabled, and the installer did the sensible (?) thing. Presumably, a clean install would have required the shenanigans described here and elsewhere.

hide preview

What's next? verify your email address for reply notifications!

Lri 12y, 233d ago

I don't know if it's because I upgraded to 10.8, but Apache was already started automatically by /System/Library/LaunchDaemons/org.apache.httpd.plist.

/etc/apache2/users/username.conf was removed though, so I had to create it again to change the DocumentRoot of virtual hosts. Mine looks like this:

NameVirtualHost *:80

<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot "/Users/username/Sites/testsite/"
ServerName testsite.dev
</VirtualHost>
hide preview

What's next? verify your email address for reply notifications!

Tom de Bruin 12y, 234d ago

The guy who makes VirtualHostX has made a handy preference pane to re-enable the web sharing option: http://clickontyler.com/blo...

remark link
hide preview

What's next? verify your email address for reply notifications!

Alan 12y, 182d ago

Funny thing about this pp is that u still have to input the admin password so it's not really useful for people who can use the Terminal.app

hide preview

What's next? verify your email address for reply notifications!

Bryan Brodie 12y, 200d ago

WIthout other manual config file changes, that PP did not work for me.

hide preview

What's next? verify your email address for reply notifications!

Tom de Bruin 12y, 234d ago

The guy who makes VirtualHostX has made a handy preference pane to re-enable the web sharing option: http://clickontyler.com/blo...

hide preview

What's next? verify your email address for reply notifications!

Jacob Mather 12y, 234d ago

Brett,

I'm surprised you would be doing this 'natively.' I would highly recommend using a VM to isolate your actual dev environment. Not only is it simply cleaner, it makes it much easier to get back up and running in the event of a system failure.

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett 12y, 234d ago

I do both. Part of it's just legacy, and part of it is "web apps" and hacks that I run locally and I don't want the weight of a VM running permanently.

hide preview

What's next? verify your email address for reply notifications!

Joel Yeaton 12y, 234d ago

I remap my caps lock key to quicksilver using KeyRemap4MacBook & PCKeyboard Hack and after 10.8 it wasn't working, and I got it to work by following this information I found on the PCKeyboardHack Github page:

You can get PCKeyboardHack for 10.7 to work with Mountain Lion by using the 10.7 kext. I'm using a couple remappings and everything seems to work great.
These are the steps I followed to make it work:
1. Download and Install PCKeyboardHack for 10.7
2. Restart
3. Edit (as sudo): /Library/org.pqrs/PCKeyboardHack/scripts/kext.sh (see below)
4. Restart

/Library/org.pqrs/PCKeyboardHack/scripts/kext.sh:

!/bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH

basedir="/Library/org.pqrs/PCKeyboardHack"
kextfile=''
uname=uname -r
case "${uname%%.*}" in
10)
kextfile="$basedir/PCKeyboardHack.10.6.kext"
;;
11)
kextfile="$basedir/PCKeyboardHack.10.7.kext"
;;
12)
kextfile="$basedir/PCKeyboardHack.10.7.kext" # Hack to use 10.7 kext in 10.8
;;
esac

if [ "x$kextfile" == 'x' ]; then
exit 1
fi

if [ "$1" == 'unload' ]; then
kextunload -b org.pqrs.driver.PCKeyboardHack
else
kextload "$kextfile"
fi

exit 0

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett 12y, 234d ago

Thanks, I'll give it a shot!

hide preview

What's next? verify your email address for reply notifications!

Joel Yeaton 12y, 234d ago
hide preview

What's next? verify your email address for reply notifications!