安裝mod_wsgi連通python和apache2問題

敲黑板:離線狀態(tài)安裝mod_wsgi 是離線安裝時出現(xiàn)的問題

查了很多關(guān)于安裝mod_wsgi的文章,之類我就不細(xì)說如何下載解壓的步驟了

  • 第一步配置安裝出現(xiàn)的問題:
    • 在執(zhí)行make命令安裝Makefile時出現(xiàn)了如下問題:

錯誤代碼

     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)問題的就是這個 -fPIC ,原因是在python在編譯的時候沒有執(zhí)行 -fPIC命令,所以重新編譯了一遍python。

步驟

cd 源碼
./configure --prefix=/usr/local/python3.8  --enable-shared CFLAGS=-fPIC
make && make install
  • 等待編譯完成

成功解決了這個問題


繼續(xù)安裝mod_wsgi
  • 在我執(zhí)行make命令安裝mod_wsgi時出現(xiàn)了新的錯誤

錯誤代碼

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.
----------------------------------------------------------------------
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容