Trouble Runinng Fink's Apache Package as Startup Item

Discussion in 'Apple' started by Aaron Davies, Aug 16, 2003.

  1. Aaron Davies

    Aaron Davies Guest

    I recently installed fink's apache package, and I'm trying to get it to
    start at boot time, but not having much luck. The first thing I tried
    was putting

    @reboot /sw/sbin/apachectl restart

    in /etc/crontab, but that didn't seem to work, so I tried the long
    route, installing it in StartupItems. I have the following:

    /Library/StartupItems/Apache% ls -l
    total 8
    drwx------ 5 adavies staff 170 Aug 15 23:02 .
    drwxrwxr-x 11 root wheel 374 Aug 13 22:01 ..
    -rwx------ 1 adavies staff 362 Aug 13 22:02 Apache
    drwx------ 4 adavies staff 136 Aug 13 21:58 Resources
    -rw------- 1 adavies staff 206 Aug 13 21:58 StartupParameters.plist

    and the contents of Apache are

    #!/bin/sh

    ##
    # Apache HTTP Server
    ##

    .. /etc/rc.common
    .. /sw/bin/init.sh

    StartService ()
    {
    ConsoleMessage "Starting Apache web server"
    apachectl start
    }

    StopService ()
    {
    ConsoleMessage "Stopping Apache web server"
    apachectl stop
    }

    RestartService ()
    {
    ConsoleMessage "Restarting Apache web server"
    apachectl restart
    }

    RunService "$1"

    StartupParameters.plist has

    {
    Description = "Apache web server";
    Provides = ("Web Server");
    Requires = ("DirectoryServices");
    Uses = ("Disks", "NFS", "Network Time");
    OrderPreference = "None";
    }

    If I say

    sudo /Library/StartupItems/Apache/Apache start

    in Terminal, it works fine, but it doesn't start when I start the
    computer. What's wrong? Incidentally, I added the

    .. /sw/bin/init.sh

    line to source the fink script because I was having path problems trying
    to run the Apache script.
     
    Aaron Davies, Aug 16, 2003
    #1
    1. Advertisements

  2. Aaron Davies

    Aaron Davies Guest

    Hello . . . hello . . . hello . . . is there anybody out there?
     
    Aaron Davies, Aug 20, 2003
    #2
    1. Advertisements

  3. In your script, I would try to specify the full path name to apachectl
    even though you're sourcing /sw/bin/init.sh. I'm not using apache
    from fink, I compiled my own apache2 and here is my startup script
    that works fine (I added APACHE2 to /etc/hostconfig for switching
    it on an off):


    #!/bin/sh

    ##
    # Apache HTTP Server
    ##

    .. /etc/rc.common

    StartService ()
    {
    if [ "${APACHE2:=-NO-}" = "-YES-" ]; then
    ConsoleMessage "Starting Apache2 web server"
    /usr/local/apache2/bin/apachectl startssl
    fi
    }

    StopService ()
    {
    ConsoleMessage "Stopping Apache web server"
    /usr/local/apache2/bin/apachectl stop
    }

    RestartService ()
    {
    if [ "${APACHE2:=-NO-}" = "-YES-" ]; then
    ConsoleMessage "Restarting Apache web server"
    /usr/local/apache2/apachectl restart
    else
    StopService
    fi
    }

    RunService "$1"

    regards
     
    read-the-signature, Aug 20, 2003
    #3
  4. Aaron Davies

    Aaron Davies Guest

    Thanks, I've implemented that and I'll give it a try next reboot. I'm
    actually moving in a couple days, so I'll see then, if not before. I try
    to avoid rebooting when I don't have to. :)
     
    Aaron Davies, Aug 21, 2003
    #4
  5. Aaron Davies

    Aaron Davies Guest

     
    Aaron Davies, Aug 21, 2003
    #5
  6. Aaron Davies

    Aaron Davies Guest

    Still doesn't seem to be working. I now have the following in hostconfig
    and the startup script. Any other ideas?

    ~% grep -i apache /etc/hostconfig
    APACHE=-YES-

    ~% cat /Library/StartupItems/Apache/Apache
    #!/bin/sh

    ##
    # Apache HTTP Server
    ##

    .. /etc/rc.common
    .. /sw/bin/init.sh

    StartService ()
    {
    if [ "${APACHE:=-NO-}" = "-YES-" ]; then
    ConsoleMessage "Starting Apache web server"
    /sw/sbin/apachectl start
    fi
    }

    StopService ()
    {
    ConsoleMessage "Stopping Apache web server"
    /sw/sbin/apachectl stop
    }

    RestartService ()
    {
    if [ "${APACHE:=-NO-}" = "-YES-" ]; then
    ConsoleMessage "Restarting Apache web server"
    /sw/sbin/apachectl restart
    else
    StopService
    fi
    }

    RunService "$1"
     
    Aaron Davies, Aug 23, 2003
    #6
  7. Aaron Davies

    Aaron Davies Guest

    Hello? Anybody? It's still not working.
     
    Aaron Davies, Sep 1, 2003
    #7
  8. Um, do you have the Resources directory and the StartupParameters.plist
    file in your startupitem folder? Are you sure you need that .
    /sw/bin/init.sh ?

    --
    Heath
    ________________________________________________________
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
     
    Heath Raftery, Sep 2, 2003
    #8
  9. Aaron Davies

    Aaron Davies Guest

    I put the init.sh in 'cause it couldn't find the right apachectl. Since
    I've given it the full path, I'll try commenting out the init.sh, but I
    doubt it will help. All that script does is set up a bunch of paths for
    Fink. Here's the contents of the Apache item folder. Is there anything
    missing?

    ~% cd /Library/StartupItems/Apache
    /Library/StartupItems/Apache% ls -lR
    ..:
    total 12
    drwx------ 6 adavies staff 204 Aug 21 03:02 .
    drwxrwxr-x 11 root wheel 374 Aug 13 23:01 ..
    -rwx------ 1 adavies staff 504 Aug 21 03:02 Apache
    -rwx------ 1 root staff 404 Aug 21 02:59 Apache~
    drwx------ 4 adavies staff 136 Aug 13 22:58 Resources
    -rw------- 1 adavies staff 206 Aug 13 22:58
    StartupParameters.plist

    Resources:
    total 0
    drwx------ 4 adavies staff 136 Aug 13 22:58 .
    drwx------ 6 adavies staff 204 Aug 21 03:02 ..
    drwx------ 3 adavies staff 102 Aug 13 22:58 English.lproj
    drwx------ 3 adavies staff 102 Aug 13 22:58 Japanese.lproj

    Resources/English.lproj:
    total 4
    drwx------ 3 adavies staff 102 Aug 13 22:58 .
    drwx------ 4 adavies staff 136 Aug 13 22:58 ..
    -rw------- 1 adavies staff 422 Aug 13 22:58
    Localizable.strings

    Resources/Japanese.lproj:
    total 4
    drwx------ 3 adavies staff 102 Aug 13 22:58 .
    drwx------ 4 adavies staff 136 Aug 13 22:58 ..
    -rw------- 1 adavies staff 440 Aug 13 22:58
    Localizable.strings
     
    Aaron Davies, Sep 2, 2003
    #9
  10. Yeah, I agree it is unlikely to cause a problem. I just thought it was the
    only thing different to other StartupItems that I could see and that it was
    probably not necessary.
    No, that looks fine.
    Apologies for not reading the start of the thread - I see what you've done
    now. The next thing I would try would probably be the permissions of the
    files in that directory. It would seem odd that the boot process couldn't
    execute your script, but still, you may want to imitate the permissions in
    other StartupItems. I'm pretty sure all this stuff is documented somewhere,
    but not sure off the top of the head. Compare the permissions of say, the
    Sendmail StartupItem to your own:

    drwxr-xr-x 3 root wheel 102 Jul 28 2002 Resources
    -rwxr-xr-x 1 root wheel 1044 Jul 28 2002 Sendmail
    -rw-r--r-- 1 root wheel 203 Jul 28 2002 StartupParameters.plist

    You might need to make your files world executable.

    Hope that helps.
     
    Heath Raftery, Sep 3, 2003
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.