敲黑板:離線狀態(tài)安裝mod_wsgi 是離線安裝時(shí)出現(xiàn)的問題
查了很多關(guān)于安裝mod_wsgi的文章恶复,之類我就不細(xì)說如何下載解壓的步驟了
- 第一步配置安裝出現(xiàn)的問題:
- 在執(zhí)行
make
命令安裝Makefile時(shí)出現(xiàn)了如下問題:
- 在執(zhí)行
錯(cuò)誤代碼
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.
- 出現(xiàn)問題的就是這個(gè) -fPIC 倘感,原因是在python在編譯的時(shí)候沒有執(zhí)行 -fPIC命令奈惑,所以重新編譯了一遍python筷登。
步驟
cd 源碼
./configure --prefix=/usr/local/python3.8 --enable-shared CFLAGS=-fPIC
make && make install
- 等待編譯完成
成功解決了這個(gè)問題
繼續(xù)安裝mod_wsgi
- 在我執(zhí)行make命令安裝mod_wsgi時(shí)出現(xiàn)了新的錯(cuò)誤
錯(cuò)誤代碼
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
原因
- 我發(fā)現(xiàn)我連python環(huán)境都進(jìn)不去绍刮,經(jīng)過查找是Linux系統(tǒng)默認(rèn)加載/usr/lib下面庫文件览爵,python默認(rèn)安裝到非此類文件夾烈拒。不過可以通過添加庫配置信息解決嚷量。
步驟
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.
----------------------------------------------------------------------