MacOS安装mod_python

做了一个django的程序,部署在Apache上,环境是MacOS10.9.2,网上查资料得知要先安装mod_python,于是安装的mod_python的痛苦经历就开始了。

1、下载mod_python源文件,戳这里http://modpython.org/,我用的是3.3.1

2、解压后到mod_python的源码目录下,执行./configure,这一步是生成makefile文件,为编译使用,网上有说在./configure后面添加参数-- with-apxs=/usr/sbin/apxs,这里的目录是我机器的目录,每个人不一样,若不知道自己的apxs文件在哪里,可以find / -name apxs,我就是这么干的,虽然粗暴,但是简单。我自己试了下,不加这个参数也可以的,./configure会自动搜索,所以也不用担心

3、最痛苦的一步来了,就是make。make的时候一开始会出现下面的错误:

Building mod_python.so.


/usr/sbin/apxs -I/var/root/Downloads/mod_python-3.4.1/src/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE -Wc,'-arch x86_64' -c mod_python.c _apachemodule.c requestobject.c tableobject.c util.c serverobject.c connobject.c filterobject.c hlist.c hlistobject.c finfoobject.c version.c include/_apachemodule.h  include/filterobject.h  include/hlist.h include/mod_python.h  include/psp_flex.h include/psp_parser.h include/requestobject.h include/tableobject.h include/connobject.h include/finfoobject.h include/hlistobject.h include/mp_version.h include/_pspmodule.h  include/psp_string.h  include/serverobject.h include/util.h -arch x86_64 -Wl,-F/System/Library/Frameworks -framework Python -u _PyMac_Error /System/Library/Frameworks/ -ldl  -framework CoreFoundation 

/usr/share/apr-1/build-1/libtool --silent --mode=compile /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/include -I/usr/include/apache2  -I/usr/include/apr-1   -I/usr/include/apr-1  -arch x86_64 -I/var/root/Downloads/mod_python-3.4.1/src/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -DENABLE_DTRACE -DMACOSX -DNDEBUG -DNDEBUG -DENABLE_DTRACE  -c -o mod_python.lo mod_python.c && touch mod_python.slo

env: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain/usr/bin/cc: No such file or directory

apxs:Error: Command failed with rc=65536

.

make[1]: *** [mod_python.so] Error 1

make: *** [do_dso] Error 2

这里可以看到错误原因就是没找到/Application/..../cc文件,我就到那个目录下去看了下,缺失不存在,怎么办呢?然后发现在/Application/Xcode.app/Contents/Developer/Toolchains/下面的XcodeDefault.xctoolchain文件夹中有/usr/bin/cc,于是就使用下面的命令,创建一个链接,然后不就可以找到cc了么。

ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain
然后这一步之后,make clean,重新make刚才那个错误就没有了,准备迎接新的错误吧:

clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command 'cc' failed with exit status 1

make[1]: *** [build] Error 1

make: *** [do_dso] Error 2

这个错误的原因查了很多地方,说的意思就是版本5.1的xcode在编译的时候更加严格(为啥用到xcode,我也不懂。。。),在对函数参数的检查上提高了等级,原来低版本中

得warning变成了error,所以此处我们要做的就是让这个参数的检查不要那么严格,于是make clean,然后

make ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
这样的话,编译就过了

4、最后一步就是make install,这一步的时候出现如下错误:

    version = "fatal: Not a git repository (or any of the parent directories): .git

                                                                                  ^

SyntaxError: EOL while scanning string literal

进入mod_python源码目录,然后进如dist子目录中,打开version.sh的文件,

To fix it, you can remove the line

GIT=`git describe --always`

and change the next line to

echo $MAJ.$MIN.$PCH-
上面是一个老外的解决办法,我试了果然就没有错误了,重新运行make install,mod_python安装完毕
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值