安装uwsgi,安装步骤如下
wget https://projects.unbit.it/downloads/uwsgi-latest.tar.gz tar zxvf uwsgi-latest.tar.gz cd <dir> python uwsgiconfig.py --build
报错
using profile: buildconf/default.ini detected include path: ['/usr/local/include', '/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include', '/usr/include'] Traceback (most recent call last): File "uwsgiconfig.py", line 1612, in <module> build_uwsgi(uc, is_cflags, gcll=gcll) File "uwsgiconfig.py", line 280, in build_uwsgi gcc_list, cflags, ldflags, libs = uc.get_gcll() File "uwsgiconfig.py", line 983, in get_gcll elif int(k_minor) >= 25: ValueError: invalid literal for int() with base 10: '32_1'
这个报错是因为python中int转换字符串的时候,默认转换的只能是数字,'32_1'显然不是一个数字,谁能想到从官网上下载的脚本居然有bug
肿木办呢?打开这个文件的源码,找到983行,代码为
if timer_mode == 'auto': if uwsgi_os == 'Linux': k_all = uwsgi_os_k.split('.') k_base = k_all[0] k_major = k_all[1] if len(k_all) > 2: k_minor = k_all[2] else: k_minor = 0 if int(k_base) > 2: timer_mode = 'timerfd' elif int(k_minor) >= 25: timer_mode = 'timerfd' else: timer_mode = 'none'
取的应该是版本号
# uname -a Linux jiu_bu_gao_su_ni 2.6.32_1-12-0-0 #1 SMP Mon Aug 12 17:59:52 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
这样在代码里强制加一个k_minor=32就可以了
if timer_mode == 'auto': if uwsgi_os == 'Linux': k_all = uwsgi_os_k.split('.') k_base = k_all[0] k_major = k_all[1] if len(k_all) > 2: k_minor = k_all[2] else: k_minor = 0 k_minor = 32 if int(k_base) > 2: timer_mode = 'timerfd' elif int(k_minor) >= 25: timer_mode = 'timerfd' else: timer_mode = 'none'
测试一下,安装成功
python uwsgiconfig.py --build
把同路径下生成的uwsgi拷贝到/usr/bin下或者/usr/sbin就可以了