简体   繁体   English

我如何用php重新加载httpd服务

[英]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.

相关问题 将“服务httpd重载”重新加载新的php.ini设置? - will “service httpd reload” reload new php.ini settings? httpd:如何了解httpd.conf中的错误在哪里 - httpd: how can I understand where the error in httpd.conf is [PHP] [CRON]如何在cron中重新加载页面? - [PHP][CRON] How can I reload page in cron? 如何使用PHP + JS重新加载页面并显示查询参数? - How can I reload a page and display a query parameter with PHP + JS? 如何在PHP中重新加载文件? - How do I reload a file in PHP? 如何在Docker容器中重新加载服务配置(php-fpm)? - How to reload service configuration (php-fpm) inside a docker container? 提交表单后,如何在php中重新加载页面(方法=发布) - How can I reload a page in php after I submit a form (method=post) Apache 2.4、PHP 7.4.7、Windows 10 无法从 Apache 服务加载 cURL 扩展,但可以通过 httpd 从命令行加载 - Apache 2.4, PHP 7.4.7, Windows 10 can't load cURL Extension from Apache Service but loads fine from Command Line with httpd 如何在Core PHP中(在每个页面上)验证用户会话并限制用户重新加载页面或返回 - How can I authenticate a user session in Core PHP (on each page) and restrict the user to reload the page or go back 在php中重新加载页面时,如何从输入中获取值并将其添加到Sql语句中? - How can i take value from input and add to Sql statement when page reload in php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM