سؤال

I have a page that is running a command line script using exec() This script makes changes to Apaches config, add's new document roots and virtual hosts etc. This script works exactly as I want.

I need to restart Apache to have the changes go live. But if I do this from the running script or via php it works but I get no feedback back from the php page as Apache has been restarted.

I've tried using reload but that does the same and stops the currently running PHP script. Is there anyway to merge the config changes to Apache with out it affecting any currently running scripts ?

I'm reloading Apache from a PHP Script using :

exec('sudo /Web/apache_reload', $res);

apache_reload contains:

/sbin/chkconfig apache2 > /dev/null
/etc/init.d/apache2 restart > /dev/null

Thanks

هل كانت مفيدة؟

المحلول

You could try using /etc/init.d/apache2 reload, which reloads the config files without killing apache.

However, there are cleaner solutions for this.

Instead of actually restarting apache, you could create an empty file i.e. /tmp/reload_apache. Then you have a script running every minute via cron that checks if this file exists, and if so it will restart apache and delete the file.

The only downside will be that you may have to wait up to 60 seconds until apache restarts.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top