Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having trouble getting Apache set up on my MacBook in Mountain Lion after I upgraded from Leopard. I tried following these instructions. I have the LoadModule php5_module libexec/apache2/libphp5.so line uncommented in /etc/apache2/httpd.conf, I have a my_user_name.conf file in /etc/apache2/users with the contents:

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

I have an index.html file in /Users/my_user_name/Sites, chmodded to 644, owned by my_user_name.

  • However, when I go to http://localhost/~my_user_name, I still get 403 Forbidden.
  • I created /Library/WebServer/Documents/phpinfo.php with <?php phpinfo(); ?> in it, and when I view that in the browser, I just see the source code.
  • When I go to http://localhost, I see "It works!". However, after I do sudo apachectl stop, if I visit http://localhost, I still see "It works!"--shouldn't that be inaccessible if I've stopped Apache?

It almost seems like there's some other web server behind my localhost, and that's why my changes to httpd.conf and my_user_name.conf aren't making any difference. Any ideas?

share|improve this question
    
@SarahVessels Do you perhaps have your install of Apache conflicting with the OS X default install? Check under the sharing control panel that "Web Sharing" is unchecked. –  Jeff Ferland Aug 25 '12 at 0:33
    
It sounds like you may have more than one Apache running -- When you stop Apache do you still see any httpd processes running in Activity Monitor (or ps auxw)? –  voretaq7 Aug 25 '12 at 1:00
    
@Jeff: 'Web Sharing' is no longer in the system settings under Mountain Lion. –  Sarah Vessels Aug 25 '12 at 3:38
    
@voretaq7: bam, that looks like the problem. Did sudo apachectl stop then ps auwx | grep httpd and got several entries like _www 3157 0.0 0.0 2436152 1776 ?? S Thu07PM 0:00.03 /usr/sbin/httpd -D FOREGROUND. So now the question: how did I get two Apaches, and what should I do to get rid of one? –  Sarah Vessels Aug 25 '12 at 3:39
add comment

2 Answers

OK, so we've established you're running multiple apache servers.

The first thing I would suggest doing is rebooting -- This is not normally a solution I recommend, but if your system is in some kind of inconsistent state with a half-dead Apache this will resolve it and get you back to a state where the normal tools will work for starting/stopping the web server.

If that fails to get you to a working state you'll have to determine where the extra httpd is coming from (you can use lsof (as root) to determine which httpd.conf file it's reading, which may contain some clues about what installed it, and how you can go about disabling or reconfiguring it)

share|improve this answer
add comment

I'm guessing the additional webserver is the one that comes built into OS X. It's still there in Mountain Lion, but the UI to enable and disable it has been removed. You can still manage it from the command line, however. OS X starts and maintains the builtin web server with launchd, so you use launchctl to manage it. First, check to see if launchd is running apache:

$ sudo launchctl list | grep apache
1526    -   org.apache.httpd

That result tells me that launchd has started an item with the label org.apache.httpd, and it's running as process ID 1526. If it didn't have an active apache item, the results would be blank.

If it's the system-supplied launchd item, you can turn it off with:

$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Note that the -w makes the unload permanent (without it, the item would be reloaded at the next reboot).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.