etc/nginx/nginx.conf
#全局配置信息
user www-data; 当前nginx启动的服务名称是什么
worker_processes auto; 开启的进程,auto自动根据电脑核心数决定,2核2个进程。一个master process 一个worker process
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
#http 配置信息
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; 包含了它的两个同级目录下的所有配置信息
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
python@ubuntu:/etc/nginx$
uwsgi.ini
[uwsgi]
#使用nginx连接时使用,Django程序所在服务器地址
socket=10.211.55.2:8001
#直接做web服务器使用,Django程序所在服务器地址
#http=10.211.55.2:8001
#项目目录
chdir=/Users/delron/Desktop/project
#项目中wsgi.py文件的目录,相对于项目目录
wsgi-file=project/wsgi.py
# 进程数
processes=4
# 线程数
threads=2
# uwsgi服务器的角色
master=True
# 存放进程编号的文件
pidfile=uwsgi.pid
# 日志文件,因为uwsgi可以脱离终端在后台运行,日志看不见。我们以前的runserver是依赖终端的
daemonize=uwsgi.log
# 指定依赖的虚拟环境
virtualenv=/Users/delron/.virtualenv/project
修改nginx文件
upstream project{
server 10.211.55.2:8001; # 此处为uwsgi运行的ip地址和端口号
# 如果有多台服务器,可以在此处继续添加服务器地址
}
#gzip on;
server {
listen 8000;
server_name api.project.site;
location / {
include uwsgi_params;
uwsgi_pass project;
}
}
server {
listen 80;
server_name www.project.site;
#charset koi8-r;
#access_log logs/host.access.log main;
location /xadmin {
include uwsgi_params;
uwsgi_pass project;
}
location /ckeditor {
include uwsgi_params;
uwsgi_pass project;
}
location / {
root /home/python/Desktop/front_end_pc;
index index.html index.htm;
}
error_page 500502503504 /50x.html;
location = /50x.html {
root html;
}
}