nginx配置笔记
2014-02-14 09:53
357 查看
系统环境: 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文件
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; server { listen 8080; server_name localhost; root /var/www/html; index index.html index.php; location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } } }
nginx + django + uwsgi
1.安装uWSGI
安装依赖包
yum install python python-devel libxml2 libxml2-devel python-setuptools zlib-devel wget openssl-devel pcre pcre-devel sudo gcc make autoconf automake python-pip
通过pip安装
pip install uWSGI
2. nginx配置文件修改.
/etc/nginx/nginx.conf
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; } }
root: django: app目录
uwsgi_pass: uwsgi服务器的地址与端口号,与uwsgi配置文件中的必须相同.
设定static和media目录的位置.
3.在django项目根目录下创建wsgi.py文件,内容如下
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()
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与PHP(FastCGI)的安装、配置与优化
- Mint+Nginx+Mysql+php
- 实现Nginx通过反代对Java环境和Perl环境的支持
- nginx的中文rewrite规则
- Nginx交互式管理脚本
- 文章3:Nginx源码分析-ngx_list_t单链表
- nginx根据cookie分流
- yum 安装 PHP,apache,nginx,mysql
- Windows下nginx的安装与配置
- Nginx 简单的负载均衡配置示例
- lvs、haproxy、nginx 负载均衡的比较分析
- Red Hat Linux 64位安装mysql+nginx+GD+php
- 编译安装nginx时pcre模块报错的解决
- nginx location修改root 出现 403
- nginx location 配置
- 我的nginx.conf配置
- Nginx 1 Web Server Implementation Cookbook系列--(1)debug mode
- nginx 里设置font-face 跨域
- Restarting nginx daemon: nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98:
- About Lua And Nginx