Mac OSX Lion Apache server takes a while to start serving php scripts

20
2014-03
  • Stian Håklev

    I use the built in Apache (web sharing) and the built in PHP in OSX Lion to run DokuWiki as a personal information manager (nobody connects externally). From the previous version of OSX, there seems to be a chance in how web sharing works, and when I first try to open a page on localhost after not having used it for a while, it takes quite a while (upwards of 45 seconds) before the server responds. Subsequent pages are very quick. I wonder if this is some kind of "sleep function" where it suspends Apache when not in use, to save energy.

    Is there a setting I can change to make it always respond right away?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    OS X Lion - apache & php setup
  • agmcleod

    I'm trying to setup the built in apache part of os x to work with php. I've gone through the process of uncommenting the php lines and so forth in the httpd.conf file. However, I can't seem to get the webserver to find any of my files to test. I changed the ListenPort to 3333, since i run https://github.com/37signals/pow on port 80. Like so:

     <IfDefine !MACOSXSERVER>
       Listen 3333
     </IfDefine>
    

    And the server seems to respond to 3333 just fine. I also setup the /etc/apache2/users/aaronmcleod.conf to store a virtual host to the ~/Sites folder like so:

    <Directory "/Users/aaronmcleod/Sites/">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
    NameVirtualHost *:3333
    
    <Virtualhost *:3333>
        DocumentRoot /Users/aaronmcleod/Sites
        ServerName aaronmcleod.dev
    </Virtualhost>
    

    However, when i go to http://localhost:3333/test.php i just receive a 404 error from apache. Any ideas on what i missed?


  • Related Answers
  • Todd Baur
    # Mac OS X / Mac OS X Server
    # The <IfDefine> blocks segregate server-specific directives
    # and also directives that only apply when Web Sharing or
    # server Web Service (as opposed to other services that need Apache) is on.
    # The launchd plist sets appropriate Define parameters.
    # Generally, desktop has no vhosts and server does; server has added modules,
    # custom virtual hosts are only activated when Web Service is on, and
    # default document root and personal web sites at ~username are only
    # activated when Web Sharing is on.
    

    This means that /etc/apache2/httpd.conf is set up with special xml tags that enable the user to enable or disable modules based on simply if you are a OS X Server or a regular OS X Desktop. Also the configuration is set so that if you go into System Preferences - Sharing - Enable Web Sharing that it configures OS X to load /etc/apache2/other/*.conf which is where you would want to consider placing your whateversite.conf file.

  • agmcleod

    Looks like if i launch apache under the sharing section of system preferences, i can get to it fine. Though i wonder why it doesn't work when starting the server via terminal.