By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,199 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,199 IT Pros & Developers. It's quick & easy.

Can i restart httpd from a php script?

P: n/a
anr
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

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
*** an*@mac.com wrote/escribió (13 Aug 2004 02:22:45 -0700):
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?


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 ;-)
--
Jul 17 '05 #2

P: n/a
an*@mac.com wrote:
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


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
Jul 17 '05 #3

P: n/a
an*@mac.com wrote:
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


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
Jul 17 '05 #4

P: n/a
"anr" wrote:
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


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
Jul 17 '05 #5

P: n/a
On Fri, 13 Aug 2004 02:22:45 -0700, anr wrote:
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?


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.

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.