首页 > 解决方案 > Apache2 在没有 LD_LIBRARY_PATH 的情况下启动

问题描述

在 Suse11 上,我在我的用户环境中设置了 LD_LIBRARY_PATH。然后我通过 apache2ctl start 启动 apache2

但我发现 LD_LIBRARY_PATH 不是由 apache2 进程继承的。我需要指定任何标志吗?

标签: linuxapache

解决方案


抱歉我忘了提一件事,我使用 sudo 来启动 http 服务器。我需要 LD_LIBRARY_PATH 因为外部 PHP 模块依赖于一些库来启动。而且我发现“sudo”命令消除了我的 LD_LIBRARY_PATH。

   Note that the dynamic linker on most operating systems will remove variables that can control dynamic linking from the environment of setuid executables,
   including sudo.  Depending on the operating system this may include _RLD*, DYLD_*, LD_*, LDR_*, LIBPATH, SHLIB_PATH, and others.  These type of variables are
   removed from the environment before sudo even begins execution and, as such, it is not possible for sudo to preserve them.

最后我用“sudo -E LD_LIBRARY_PATH=$LD_LIBRARY_PATH apache2ctl start”启动http服务器来设置LD_LIBRARY_PATH。


推荐阅读