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; }}}python 没安装的需要安装
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-8from flup.server.fcgi import WSGIServerdef 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
安装驱动