敲黑板:离线状态安装mod_wsgi 是离线安装时出现的问题
查了很多关于安装mod_wsgi的文章,之类我就不细说如何下载解压的步骤了
- 第一步配置安装出现的问题:
- 在执行
make
命令安装Makefile时出现了如下问题:
- 在执行
错误代码
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object;
recompile with -fPIC.
/usr/local/lib/libpython3.8m.a: could not read symbols: Bad value.
- 出现问题的就是这个 -fPIC ,原因是在python在编译的时候没有执行 -fPIC命令,所以重新编译了一遍python。
步骤
cd 源码
./configure --prefix=/usr/local/python3.8 --enable-shared CFLAGS=-fPIC
make && make install
- 等待编译完成
成功解决了这个问题
继续安装mod_wsgi
- 在我执行make命令安装mod_wsgi时出现了新的错误
错误代码
src/server/wsgi_python.h:24:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1
原因
- 我发现我连python环境都进不去,经过查找是Linux系统默认加载/usr/lib下面库文件,python默认安装到非此类文件夹。不过可以通过添加库配置信息解决。
步骤
cd /etc/ld.so.conf.d
vim python3.conf
编辑 添加库文件路径 /usr/local/python3.8/lib
保存、退出
ldconfig 重新加载config
回过头去安装mod_wsgi终于成功了
Libraries have been installed in:
/usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------