要部署Django项目,需要进行以下步骤:
sudo apt-get install nginx
sudo apt-get install uwsgi uwsgi-plugin-python
/etc/nginx/sites-available/default
。将以下内容添加到server
块中:location / {
uwsgi_pass unix:///path/to/your/project/project.sock;
include uwsgi_params;
}
uwsgi.ini
文件,并添加以下内容:[uwsgi]
http-timeout = 86400
http-timeout-keepalive = 86400
http-timeout-buffers = 4096
socket = /path/to/your/project/project.sock
chmod-socket = 666
plugin = python
wsgi-file = /path/to/your/project/project/wsgi.py
uwsgi --ini /path/to/your/project/uwsgi.ini
sudo service nginx start
现在,您的Django项目应该已经成功部署在Nginx上了。您可以通过服务器的IP地址或域名访问您的项目。记得替换掉命令和配置文件中的/path/to/your/project
为您的项目实际路径。