要部署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
為您的項目實際路徑。