博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux nginx python flup spawn-fcgi
阅读量:7005 次
发布时间:2019-06-27

本文共 2999 字,大约阅读时间需要 9 分钟。

hot3.png

  1. nginx-1.8.1.tar.gz 安装

    ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre --add-module=/home/nginx/nginx-upload-module-2.2 

    配置

    user nobody nobody;

    worker_processes 2;
    error_log /usr/local/nginx/logs/nginx_error.log crit;
    pid /usr/local/nginx/logs/nginx.pid;
    worker_rlimit_nofile 51200;
    events
    {
        use epoll;
        worker_connections 6000;
    }
    http
    {
        include mime.types;
        default_type application/octet-stream;
        server_names_hash_bucket_size 3526;
        server_names_hash_max_size 4096;
        log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
        '$host "$request_uri" $status'
        '"$http_referer" "$http_user_agent"';
        sendfile on;
        tcp_nopush on;
        keepalive_timeout 30;
        client_header_timeout 3m;
        client_body_timeout 3m;
        send_timeout 3m;
        connection_pool_size 256;
        client_header_buffer_size 1k;
        large_client_header_buffers 8 4k;
        request_pool_size 4k;
        output_buffers 4 32k;
        postpone_output 1460;
        client_max_body_size 10m;
        client_body_buffer_size 256k;
        client_body_temp_path /usr/local/nginx/client_body_temp;
        proxy_temp_path /usr/local/nginx/proxy_temp;
        fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
        fastcgi_intercept_errors on;
        tcp_nodelay on;
        gzip on;
        gzip_min_length 1k;
        gzip_buffers 4 8k;
        gzip_comp_level 5;
        gzip_http_version 1.1;
        gzip_types text/plain application/x-javascript text/css text/htm application/xml;
    server
    {
        listen 80;
        server_name localhost;
        index index.html index.htm index.php;
        root /usr/local/nginx/html;
        #rewrite ^/ /hao/index.php;
        location / {
            include fastcgi.conf;
            #rewrite ^/ /usr/local/nginx/html/hao/index.php last;
        fastcgi_pass 127.0.0.1:8008;
        }
    }
    }

  2. python 没安装的需要安装

  3. flup-1.0.2.tar.gz 安装

            解压 tar zxvf flup-1.0.2.tar.gz.

            安装 python setup.py install

      4. flup 直接运行

            python 脚本

            vim fcgi.py

    import flup.server.fcgi as flups

  def myapp(environ, start_response):
    start_response("200 OK",[('Content-Type','xml')])
    return ['Hello World!\n']
if __name__=='__main__':
   # WSGIServer(myapp,bindAddress=('127.0.0.1',8008)).run()
   flups.WSGIServer(myapp,bindAddress=('127.0.0.1',8008)).run()
   #WSGIServer(myapp).run()

python fcgi.py --method=prefork/threaded minspare=50 maxspare=50 maxchildren=1000

直接执行。

5. spawn-fcgi-1.6.4.tar.gz

解压 tar zxvf spawn-fcgi-1.6.4.tar.gz

./configure

make

make install

6.spawn-fcgi 运行

vim fcgi.py

#!/usr/bin/python

#encodiong:utf-8
from flup.server.fcgi import WSGIServer
def myapp(environ, start_response):
    start_response("200 OK",[('Content-Type','xml')])
    return ['Hello World!\n']
if __name__=='__main__':
   # WSGIServer(myapp,bindAddress=('127.0.0.1',8008)).run()
   #flups.WSGIServer(myapp,bindAddress=('127.0.0.1',8008)).run()
   WSGIServer(myapp).run()

spawn-fcgi -f /home/python_test/fcgi.py -a 127.0.0.1 -p 8008 -u hao

spawn-fcgi -d /home/python_code/  -f /home/python_code/fcgi.py -a 127.0.0.1 -p 8008 -F 1 

-F 进程数

运行

6.在浏览器中输入地址看到

Hello World!

7. mysql支持

下载mysql 驱动 MySQL-python-1.2.5

python setup.py install

安装驱动 

转载于:https://my.oschina.net/u/1445488/blog/633610

你可能感兴趣的文章
cgo的指针传递
查看>>
JS 实现抛物线动画
查看>>
前端是不是大于后端?
查看>>
小程序onLaunch,onLoad 执行生命周期
查看>>
容器化应用: Minishift 搭建镜像仓库的可视化管理控制台
查看>>
Canvas 涂鸦
查看>>
webpack模块化原理-Code Splitting
查看>>
如何从两个List中筛选出相同的值
查看>>
.NET Core 2将Visual Basic带到了Linux和macOS平台
查看>>
前端程序员需要掌握的几个专业“词语”
查看>>
PHP最佳实践之数据库
查看>>
【拾遗补缺】java ArrayList的不当使用导致的ConcurrentModificationException问题
查看>>
js 正则表达式
查看>>
使用vue和d3.js实现的dialog,messagebox,confirm,alert弹框
查看>>
Jackson 使用 defaultTyping 实现通用的序列化和反序列化
查看>>
React 更新视图过程
查看>>
第k个排列
查看>>
js数值精度
查看>>
JavaScript 中 apply 、call 的详解
查看>>
设计模式系列·王小二需求历险记(二)
查看>>