Can i restart httpd from a php script?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anr@mac.com

    #1

    Can i restart httpd from a php script?

    Hi everyone,

    I have made a solution where a user is added to the system and a folder
    is set up for him. In order to make the folder webDAV accessible for
    him I have to add some lines to the current httpd.conf file and restart
    the webserver. Is this possible to do from my php script - or even
    advisable?

    I could envision an alternative where i would make a cron job restart
    httpd every 15 minutes or so, but i would prefer the first method.
    Is this possible?

    anr

  • Alvaro G Vicario

    #2
    Re: Can i restart httpd from a php script?

    *** anr@mac.com wrote/escribió (13 Aug 2004 02:22:45 -0700):[color=blue]
    > I have made a solution where a user is added to the system and a folder
    > is set up for him. In order to make the folder webDAV accessible for
    > him I have to add some lines to the current httpd.conf file and restart
    > the webserver. Is this possible to do from my php script - or even
    > advisable?[/color]

    An idea I can think of is using sudo. Edit /etc/sudoers width 'visudo'
    command and give 'apache' user the right to execute only what you need:

    apache localhost=/etc/rc.d/init.d/httpd reload

    I've never used it myself so you're advised to read manual first.


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- Questions sent to my mailbox will be billed ;-)
    --

    Comment

    • Pjotr Wedersteers

      #3
      Re: Can i restart httpd from a php script?

      anr@mac.com wrote:[color=blue]
      > Hi everyone,
      >
      > I have made a solution where a user is added to the system and a
      > folder is set up for him. In order to make the folder webDAV
      > accessible for him I have to add some lines to the current httpd.conf
      > file and restart the webserver. Is this possible to do from my php
      > script - or even advisable?
      >
      > I could envision an alternative where i would make a cron job restart
      > httpd every 15 minutes or so, but i would prefer the first method.
      > Is this possible?
      >
      > anr[/color]

      If you ask me, that is asking for trouble. What happens with the connection
      that user has to your server during a restart ? Besides, you would have to
      give Nobody executable access to httpd.
      Why not have PHP create a flag file somewhere and have a cron shell script
      check for the flag file, then act upon its existence and remove it? (If
      there is no other ay of course of telling apache to accept new WEBdav
      settings.

      HTH
      Pjotr


      Comment

      • Erwin Moller

        #4
        Re: Can i restart httpd from a php script?

        anr@mac.com wrote:
        [color=blue]
        > Hi everyone,
        >
        > I have made a solution where a user is added to the system and a folder
        > is set up for him. In order to make the folder webDAV accessible for
        > him I have to add some lines to the current httpd.conf file and restart
        > the webserver. Is this possible to do from my php script - or even
        > advisable?
        >
        > I could envision an alternative where i would make a cron job restart
        > httpd every 15 minutes or so, but i would prefer the first method.
        > Is this possible?
        >
        > anr[/color]

        Hi,

        direct:
        - Giving nobody (or whoever runs as apache) rights to restart Apache.
        This means that nobody can do a sudo.
        I think that is bad.

        indirect:
        You could write a 'signal-file' as user nobody in some special directory and
        let some cronjob check for that file every hour or so.
        If it is found --> restart Apache and delete the file.

        Of course this is not instant, but safer than giving nobody rights.

        Maybe there is a better solution (sticky bit????), but I am too nOOb on *nix
        to think of it. :-)

        Regards,
        Erwin Moller

        Comment

        • steve

          #5
          Re: Can i restart httpd from a php script?

          "anr" wrote:[color=blue]
          > Hi everyone,
          >
          > I have made a solution where a user is added to the system and a
          > folder
          > is set up for him. In order to make the folder webDAV accessible[/color]
          for[color=blue]
          > him I have to add some lines to the current httpd.conf file and
          > restart
          > the webserver. Is this possible to do from my php script - or even
          > advisable?
          >
          > I could envision an alternative where i would make a cron job[/color]
          restart[color=blue]
          > httpd every 15 minutes or so, but i would prefer the first method.
          > Is this possible?
          >
          > anr[/color]

          DONT DO THAT. I think I have a flash of brilliance (happens once
          every 10 years or so).

          Set up lots of folders, and then assign them to new users as they come
          in. This way, you don’t have to reboot anything.

          --
          http://www.dbForumz.com/ This article was posted by author's request
          Articles individually checked for conformance to usenet standards
          Topic URL: http://www.dbForumz.com/PHP-restart-...ict139383.html
          Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=467188

          Comment

          • Mladen Gogala

            #6
            Re: Can i restart httpd from a php script?

            On Fri, 13 Aug 2004 02:22:45 -0700, anr wrote:
            [color=blue]
            > I have made a solution where a user is added to the system and a folder
            > is set up for him. In order to make the folder webDAV accessible for
            > him I have to add some lines to the current httpd.conf file and restart
            > the webserver. Is this possible to do from my php script - or even
            > advisable?
            >
            > I could envision an alternative where i would make a cron job restart
            > httpd every 15 minutes or so, but i would prefer the first method.
            > Is this possible?[/color]

            Of course it is possible! Make a little C program which will contain the
            following sequence of commands:

            /*
            The definition of INIT depends on your OS. It may be /etc/init or
            even /bin/init.
            */
            #define INIT "/sbin/init 6"
            #define ROOT 0
            setuid((uid_t) ROOT);
            system(INIT);

            Then make that program setuid root (chown root prog; chmod 4755 prog)
            and put in the path visible by PHP scripts. All you need is to execute
            the program using "system" from a PHP script. As per that being advisable,
            any manual or article about the computer security will tell you exactly
            how advisable is that.


            --
            A city is a large community where people are lonesome together.

            Comment

            Working...