uwsgi nginx部署django项目
时间: 2023-07-24 20:09:47 浏览: 132
Centos部署django服务nginx+uwsgi的方法
好的,我可以为您提供uwsgi和nginx部署Django项目的基本步骤:
1. 安装uwsgi和django
```
pip install uwsgi
pip install django
```
2. 创建uwsgi配置文件,例如uwsgi.ini,内容如下:
```
[uwsgi]
# django-related configuration
# the base directory (full path)
chdir=/path/to/your/project
# Django's wsgi file
module=your_project.wsgi:application
# the virtualenv (full path)
home=/path/to/your/virtualenv
# process-related configuration
# master
master=True
# maximum number of worker processes
processes=4
# the socket (use the full path to be safe
socket=/path/to/your/project/your_project.sock
# permissions for the socket file
chmod-socket=666
# clear environment on exit
vacuum=true
```
3. 创建nginx配置文件,例如your_project.conf,内容如下:
```
server {
listen 80;
server_name your_domain_name.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /path/to/your/project;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/path/to/your/project/your_project.sock;
}
}
```
4. 启动uwsgi和nginx服务
```
uwsgi --ini /path/to/uwsgi.ini
service nginx start
```
这样,您的Django项目就可以通过nginx进行访问了。
阅读全文