问题描述:
在使用apache和wsgi部署环境时候,从官网下载压缩包安装mod_wsgi的方式部署,编译出错,如下:
root@iZm5eftx94e1dmwqla5qoxZ:/home/mod_wsgi-4.7.1# ./configure --with-apxs=/usr/bin/apxs --with-python=/usr/lib/python3.6
root@iZm5eftx94e1dmwqla5qoxZ:/home/mod_wsgi-4.7.1# make
/usr/bin/apxs -c -Wc,-g -Wc,-O2 src/server/mod_wsgi.c src/server/wsgi_*.c -L -L -lpython
/usr/share/apr-1.0/build/libtool --silent --mode=compile --tag=disable-static i686-linux-gnu-gcc -std=gnu99 -prefer-pic -pipe -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -g -O2 -c -o src/server/mod_wsgi.lo src/server/mod_wsgi.c && touch src/server/mod_wsgi.slo
In file included from src/server/mod_wsgi.c:22:0:
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
.
原因分析
我的配置地址写错了,python的地址是【/usr/bin/python3.6】不是【/usr/lib/python3.6】
root@iZm5eftx94e1dmwqla5qoxZ:/home/mod_wsgi-4.7.1# whereis apxs
apxs: /usr/bin/apxs /usr/share/man/man1/apxs.1.gz
root@iZm5eftx94e1dmwqla5qoxZ:/home/mod_wsgi-4.7.1# whereis python
python: /usr/bin/python /usr/bin/python3.4m-config /usr/bin/python3.6m-config /usr/bin/python2.7 /usr/bin/python3.6m /usr/bin/python3.4-config /usr/bin/python3.4 /usr/bin/python3.6-config /usr/bin/python2.7-config /usr/bin/python3.6 /usr/bin/python3.4m /etc/python /etc/python2.7 /etc/python3.4 /etc/python3.6 /usr/lib/python2.7 /usr/lib/python3.4 /usr/lib/python3.6 /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/local/lib/python3.6 /usr/include/python2.7 /usr/include/python3.6m /usr/include/python3.4 /usr/include/python3.6 /usr/include/python3.4m /usr/share/python /usr/share/man/man1/python.1.gz
正确配置代码:
root@iZm5eftx94e1dmwqla5qoxZ:/home/mod_wsgi-4.7.1# ./configure --with-apxs=/usr/bin/apxs --with-python=/usr/bin/python3.6