首页 > 其他 > 详细

nginx配置笔记

时间:2014-02-14 23:02:37      阅读:576      评论:0      收藏:0      [点我收藏+]
系统环境: CentOS6.4 x64

nginx+php配置
1.安装php-fpm
yum install php-fpm -y
service php-fpm start
chkconfig php-fpm on

2.编辑 /etc/nginx/nginx.conf文件
bubuko.com,布布扣
 1 user  nginx;
 2 worker_processes  1;
 3 
 4 error_log  /var/log/nginx/error.log warn;
 5 pid        /var/run/nginx.pid;
 6 
 7 
 8 events {
 9     worker_connections  1024;
10 }
11 
12 
13 http {
14     include       /etc/nginx/mime.types;
15     default_type  application/octet-stream;
16 
17     log_format  main  $remote_addr - $remote_user [$time_local] "$request" 
18                       $status $body_bytes_sent "$http_referer" 
19                       "$http_user_agent" "$http_x_forwarded_for";
20 
21     access_log  /var/log/nginx/access.log  main;
22 
23     sendfile        on;
24     #tcp_nopush     on;
25 
26     keepalive_timeout  65;
27 
28     #gzip  on;
29 
30     include /etc/nginx/conf.d/*.conf;
31     server
32     {
33         listen  8080;
34         server_name     localhost;
35         root            /var/www/html;
36         index           index.html index.php;
37         location        ~* \.php$ {
38             fastcgi_pass 127.0.0.1:9000;
39             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
40             fastcgi_param PATH_INFO $fastcgi_script_name;
41             include fastcgi_params;
42         }
43     }
44 }

 

bubuko.com,布布扣

 

nginx + django + uwsgi

 1.安装uWSGI

  通过pip安装,如果没有的话 yum install python-pip.

 2. nginx配置文件修改.
  /etc/nginx/nginx.conf

bubuko.com,布布扣
server {
        listen   80;
        server_name 172.16.253.160;

        location / {
            root /var/www/html/PillarsCGSystem;
            uwsgi_pass 127.0.0.1:8630;
            include uwsgi_params;
            access_log off;
        }

        location /static {
            alias /var/www/html/PillarsCGSystem/static;
        }

        location /media {
            alias /var/www/html/PillarsCGSystem/media;
        }
    }
bubuko.com,布布扣

  root: django:  app目录
  uwsgi_pass:  uwsgi服务器的地址与端口号,与uwsgi配置文件中的必须相同.
  设定static和media目录的位置.

3.在django项目根目录下创建wsgi.py文件,内容如下

bubuko.com,布布扣
import os,sys

if not os.path.dirname(__file__) in sys.path[:1]:
    sys.path.insert(0, os.path.dirname(__file__))

os.environ[DJANGO_SETTINGS_MODULE] = ‘项目名称.settings

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
bubuko.com,布布扣

4.django项目根目录下创建django.xml文件,内容如下.

<uwsgi>
    <socket>127.0.0.1:8630</socket>
    <chdir>/var/www/html/PillarsCGSystem</chdir>
    <pythonpath>..</pythonpath>
    <module>wsgi</module>
</uwsgi>

5.启动uwsgi服务器.

 uwsgi -x django.xml

nginx配置笔记

原文:http://www.cnblogs.com/viator42/p/3542872.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!