Colorful Life2010

nginx上用uwsgi跑python,用fpm跑php

还是给自己备忘用的

1.安装nginx就不说了

2. 安装uwsgi

apt-get install uwsgi-core uwsgi-plugin-python

然后配置uwsgi的启动,

[uwsgi]
#uid = www-data
#gid = www-data
plugins = cgi
http-modifier1 = 0
socket = 127.0.0.1:
chdir = /var/wwwroot/
wsgi-file = /path/to/your/dir/app.py
cgi-helper=.py=python

然后再配置supervisor来监控uwsgi的进程就可以了,顺便可以把supervisor加入到upstart达一开机自动启动的目的。

3.nginx这边把请求丢给uwsgi就行了。

serve python with uwsgi$
location / {
  include uwsgi_params;
  uwsgi_pass 127.0.0.1:9000;
}

 

4.然后是php,当然要先安装

apt-get php5-common php5-fpm php5-gd(这个是图片处理的,根据需要安装)

然后去修改nginx的配置 /etc/nginx/fastcgi_params(参考http://wiki.nginx.org/PHPFcgiExample)

这个文件里默认的少两个参数,将下面两行加进去就行

fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO
$fastcgi_path_info;

然后修改nginx的host配置,让php通过fastcgi跑起来

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }

fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
历史上的今天: [2007/04/22]浪费是犯罪,我要代罪补功~~
[2007/04/22]照片记录开花的生活
[2005/04/22]春游喽~~

[nginx上用uwsgi跑python,用fpm跑php]的回复

Post a Comment~