httpd服务启动之前的源脚本

回到过去的美好时代,我可以使用一些额外的代码来修补/etc/rc.d/init.d/httpd,这些代码在每一个apache启动时执行:

start() { echo "Setting variables..." source /path/to/my/script.sh echo -n $"Starting $prog: " check13 || exit 1 LANG=$HTTPD_LANG daemon $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } 

source /path/to/my/script.sh负责设置PHP扩展所需的一些环境variables。

无论如何,在systemd之后,systemctl占上风我无法configuration我的系统在Apache启动之前自动加载script.shvariables。 手动执行时:

 /usr/sbin/httpd -k stop source /path/to/my/script.sh /usr/sbin/httpd -k start 

一切正常。

在使用systemd服务pipe理器的Fedora 4.0和类似系统上实现这一点的正确方法是什么?

您必须在单元configuration文件中使用ExecStartPre选项。 Plz,阅读http://www.freedesktop.org/software/systemd/man/systemd.service.html