- 项目目录:
/root/app
- Uwsgi的配置文件
[uwsgi]# Python扩展包安装的地方pythonpath=/usr/local/src/python3/lib/python3.5/site-packages # Django根目录chdir=/root/app# wsgi.py跟根目录的相对路径wsgi-file=app/wsgi.py# 设置Django的配置文件env = DJANGO_SETTINGS_MODULE=app.settings# 启动模块module=app.wsgi:application# 配置生成的sock文件的权限chmod-socket = 664 # 监听的IP和端口socket=:8081# 允许主线程存在master=true# 开启的进程数量processes=2# 监控python模块mtime来触发重载 (只在开发时使用)py-autoreload=1 # 在每个worker而不是master中加载应用lazy-apps=true # 设置用于uwsgi包解析的内部缓存区大小为64k。默认是4k。buffer-size = 32768 # 允许用内嵌的语言启动线程。这将允许你在app程序中产生一个子线程enable-threads = true # 多站模式vhost=true # 多站模式时不设置入口模块和文件no-site=true# 子进程数workers=2 reload-mercy=10# 当服务器退出的时候自动清理环境,删除unix socket文件和pid文件vacuum=true# 一个请求花费的时间超过了这个harakiri超时时间,那么这个请求都会被丢弃,并且当前处理这个请求的工作进程会被回收再利用(即重启)harakiri = 60 max-requests=1000limit-as=512buffer-size=30000# 设置socket的监听队列大小(默认:100)listen = 120 # 指定pid文件pidfile=/var/run/uwsgi_8081.pid# 使进程在后台运行,并将日志打到指定的日志文件或者udp服务器daemonize=/var/run/uwsgi_8081.log# 设置最大日志文件大小log-maxsize = 5000000 # 禁用请求日志记录disable-logging = true
启动命令:
uwsgi --ini /root/app/uwsgi.ini
目录结构
├── app│ ├── __init__.py│ ├── __pycache__│ │ ├── __init__.cpython-35.pyc│ │ ├── settings.cpython-35.pyc│ │ ├── urls.cpython-35.pyc│ │ └── wsgi.cpython-35.pyc│ ├── settings.py│ ├── urls.py│ └── wsgi.py├── appv1│ ├── admin.py│ ├── apps.py│ ├── __init__.py│ ├── migrations│ │ └── __init__.py│ ├── models.py│ ├── __pycache__│ │ ├── admin.cpython-35.pyc│ │ ├── __init__.cpython-35.pyc│ │ └── models.cpython-35.pyc│ ├── tests.py│ └── views.py├── manage.py└── uwsgi.ini
- nginx配置
upstream apachephp { server 127.0.0.1:8081;}server { listen 80; server_name luffy.cyqit.com; root html; index index.html index.htm index.php; include /application/nginx/conf/conf.d/gzip/gzip.conf; ## send request back to apache ## location / { include uwsgi_params; uwsgi_pass apachephp; uwsgi_param UWSGI_SCRIPT app.wsgi; uwsgi_param UWSGI_CHDIR /root/app/; index index.html index.htm; client_max_body_size 35m; }}