这是我简单的hello世界FastCGI的脚本用C写的。
This is my simple hello-world FastCGI script written in C.
#include "fcgi_stdio.h" #include <stdlib.h> void main(void) { int count = 0; while(FCGI_Accept() >= 0) printf("Content-type: text/html\r\n" "\r\n" "<title>FastCGI Hello!</title>" "<h1>FastCGI Hello!</h1>" "Request number %d running on host <i>%s</i>\n", ++count, getenv("SERVER_NAME")); }如果我使用静态链接编译它,它工作正常。
It works fine if I compiled it using static linking.
gcc -o "test.fcg" "test.c" /usr/local/lib/libfcgi.a但使用动态链接时...
But when using dynamic linking...
gcc -o "test.fcg" -lfcgi "test.c"它没有蒙山以下错误Apache的 error_log中。
/var/www/fcgi-bin/test.fcg: error while loading shared libraries: libfcgi.so.0: cannot open shared object file: No such file or directory [Thu Mar 05 14:04:22.707096 2015] [:warn] [pid 6544] FastCGI: (dynamic) server "/var/www/fcgi-bin/test.fcg" (pid 6967) terminated by calling exit with status '127' [Thu Mar 05 14:04:22.707527 2015] [:warn] [pid 6544] FastCGI: (dynamic) server "/var/www/fcgi-bin/test.fcg" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds所以我告诉Apache和的mod_fastcgi寻找它位于哪里设置 LD_LIBRARY_PATH 变量的httpd.conf ...
SetEnv LD_LIBRARY_PATH /usr/local/lib...和 fastcgi.conf 。
FastCgiConfig -initial-env LD_LIBRARY_PATH=/usr/local/lib -idle-timeout 20 -maxClassProcesses 1使用静态链接的脚本, GETENV(LD_LIBRARY_PATH)收益的/ usr / local / lib目录,但动态链接脚本仍然不抛发现错误的 libfcgi.so.0 。
Using a static-linked script, getenv("LD_LIBRARY_PATH") returns /usr/local/lib, but dynamic-linked scripts are still throwing not found errors for libfcgi.so.0.
任何想法,使这项工作?
Any ideas to make this work?
先谢谢了。
推荐答案我和nginx的类似的问题,我用 rpath的选项固定它。
I had similar issue with nginx, I fixed it by using rpath option.
不知道它会与Apache的帮助。尝试建立您的二进制文件是这样的:
Not sure if it will help with Apache. Try building your binary like this:
gcc test.c -Wl,-rpath /usr/local/lib -lfcgi -o test.fcg请确保该库文件 libfcgi.so.0 是present在的/ usr / local / lib目录。
Make sure the library file libfcgi.so.0 is present at /usr/local/lib.
如果你没有访问的/ usr / local / lib目录,然后创建了 LIB 文件夹你的 $ HOME ,和那里复制库文件。并更新 rpath的指向那里。例如,如果你的 $ HOME 是 /家庭/ XYZ ,那么你会像建:
If you don't have access to /usr/local/lib, then create the lib folder in your $HOME, and copy the library file there. And update the rpath to point to there. For example, if your $HOME is /home/xyz, then you would build like:
gcc test.c -Wl,-rpath /home/xyz/lib -lfcgi -o test.fcg有时我用这种伎俩来加载新的库比什么是安装在系统上。
Sometimes I use this trick to load newer libraries than what is installed on the system.
更多推荐
在Apache中2.4.6和的mod
发布评论