简体   繁体   中英

how can i reload the httpd service with php

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM