使用Nginx与django和uwsgi的麻烦

时间:2015-09-10 03:04:18

标签: python django nginx

我按照http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html中的步骤操作,但是当所有步骤完成而没有任何错误时,我访问127.0.0.1:8000,它会响应超时,我的nginx日志显示

  

上游超时(110:连接超时),同时从上游读取响应头

顺便说一下,我可以访问127.0.0.1:8001,其中uwsgi和django运行良好。 我也可以访问127.0.0.1:8000/image/1.jpg中的图像,但是无法访问127.0.0.1:8000

这是我的nginx.conf

Building native extensions with: '--use-system-libraries'
This could take a while...
Building nokogiri using system libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /home/falak/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20150909-23169-twqmu6.rb extconf.rb --use-system-libraries
Building nokogiri using system libraries.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/falak/.rvm/rubies/ruby-2.2.3/bin/$(RUBY_BASE_NAME)
    --help
    --clean
    --use-system-libraries
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
    --with-libxml-2.0-config
    --without-libxml-2.0-config
    --with-pkg-config
    --without-pkg-config
/home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
    from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
    from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:637:in `try_ldflags'
    from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:1780:in `pkg_config'
    from extconf.rb:338:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /home/falak/.rvm/gems/ruby-2.2.3/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /home/falak/.rvm/gems/ruby-2.2.3/extensions/x86_64-linux/2.2.0/nokogiri-1.6.2.1/gem_make.out

我使用upstream django { server 127.0.0.1:8001; } server { listen 8000; server_name 127.0.0.1 charset utf-8; client_max_body_size 75M; location /media { alias /home/zhaolei/virtualdjango/bin/mysite/media; } location /image { alias /home/zhaolei/virtualdjango/bin/mysite/image; } location / { uwsgi_pass django; include /home/zhaolei/virtualdjango/bin/mysite/uwsgi_params; } } 来运行uwsgi。我在https://github.com/nginx/nginx/blob/master/conf/uwsgi_params

中使用uwsgi --http 127.0.0.1:8001 --chdir=mysite --module=mysite.wsgi 个主机

0 个答案:

没有答案