[英]how can i reload the httpd service with php
how can you reload the httpd service from php? 如何从php重新加载httpd服务?
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. 我有没有控制面板的LAMP,并且正在通过php添加子域,并且需要在我创建的每个conf文件之后重新加载httpd服务。
Most likely your webserver is running as root. 您的网络服务器很可能以root用户身份运行。 Therefore, reloading it requires root as well.
因此,重新加载它也需要root用户。 In that case you can use sudo to restart it.
在这种情况下,您可以使用sudo重新启动它。 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).
但是,除非php脚本以vhost用户身份运行,否则其他vhost的用户也将能够执行此操作(如果他们以某种方式找出要调用的命令)。 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.
在任何时候,都可以先使用apachectl configtest来验证配置,然后再重新加载,以查看配置是否可重新加载而没有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.