0

how can you reload the httpd service from php?

I have tried:

system("/bin/echo '/sbin/service httpd reload > /dev/null 2>&1' | /usr/bin/at now");

but it seemed to only work once

i have LAMP with no control panel and am adding subdomains via php and need to reload the httpd service after each conf file i create.

2
  • You could look into mass virtual hosting - then you wouldn't need to restart the server when you want a new website for a (sub)domain Aug 31, 2011 at 7:31
  • that would work great for me, but i have mounted servers for additional space where users get created in. so i can't be certain which mount point a user is in at any given time.
    – Eli
    Aug 31, 2011 at 7:34

1 Answer 1

0

Most likely your webserver is running as root. Therefore, reloading it requires root as well. In that case you can use sudo to restart it. However, unless php scripts run as the vhost user, users from other vhosts will be able to do that too (if they somehow figure out which command to call). At any time, use apachectl configtest first to validate the config before reloading it, just to see if the config is reloadable without any problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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