是否有可能在阿帕奇启动时启动一个PHP脚本

是否有可能在阿帕奇启动时启动一个PHP脚本

本文介绍了是否有可能在阿帕奇启动时启动一个PHP脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我想知道是否有可能自动启动一个PHP脚本当Apache重新启动完成。

As the title says, I want to know if it is be possible to automatically launch a PHP script when a restart of apache is done.

更多信息编辑:

我会尽量解释什么是这样做的目的,尽​​我所能。目前,我们正在重构我们的应用程序,我们会暂时2型动物的配置文件系统被卡住,直到所有的应用流的是重构(可能需要一年多)。老一种是使用简单的平面文件中的key = value的格式(即www.conf),而新的系统将使用缓存的PHP文件(即www.php)。我们需要复制到www.php在www.conf所做的任何配置更改。

I will try to explain what is the purpose of this, the best I can. We are currently refactoring our application and we'll be stuck with 2 differents configuration file system for the time being, until all of the application flows are refactored (might take more than a year). The old one is using simple flat file in the key=value format (i.e. www.conf), while the new system will use cacheable php files (i.e. www.php). We need to replicate to www.php any config changes made in www.conf.

因为Apache被重新启动,每当有www.conf一个配置的变化,我想这可能是一个很好的解决方法解决方案推出PHP脚本,将复制到www.conf www.php。

Since Apache gets restarted whenever there is a config change in www.conf, I thought it might be a good workaround solution to launch a PHP script, that would replicate the www.conf to www.php.

推荐答案

您需要修改你的启动脚本你的Apache。

You need to modify you startup script for your apache.

打开你的启动脚本,它应该是在/etc/init.d/apache或Apache2的

Open your startup script, it should be in /etc/init.d/apache or apache2

搜索启动/重启部分,并添加您的CLI要求你的PHP脚本。

Search for the start / restart section and add your cli call for your PHP script.

例如:

    restart)
            [..]
            php -q /tmp/myscript.php &
            ;;

在哪里/tmp/myscript.php是要启动你的PHP脚本。

Where /tmp/myscript.php is your php script that you want to launch.

在&放大器;在年底将开始在后台脚本,以便你的启动不会等到你的PHP脚本已经结束。如果你要等到它已经结束,取出放&;

The "&" at the end will start the script in the background so your startup will not wait until your php script has ended. If you want to wait until it has ended, remove the &.

您不应该把这样的东西进入你的启动脚本,可能会有更好的解决方案。什么是想达到什么目的?

You should not put such thing into your startup scripts, there might be better solutions. What are trying to achieve?

这篇关于是否有可能在阿帕奇启动时启动一个PHP脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 01:14