我正在处理 https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 .我已经到了最后,按照指示启动了 uwsgi 和 nginx。 据我所知,我已经能够完成所有步骤,包括 uwsgi。
我的测试 django 站点在/home/deploy/sample 中,如屏幕截图所示
如果我
sudo vim /etc/nginx/sites-available/sample
我明白了:
server {
listen 80;
server_name sample.com www.sample.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/deploy/sample;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/sample.sock;
}
}
在“安装和配置 Nginx 作为反向代理”下,文章指出:
Inside, we can start our server block by indicating the port number and domain name where our first project should be accessible. We'll assume that you have a domain name for each:
我还没有设置域,但我想在浏览器中打开我的 VPS 的 ip 地址以查看测试站点。
我怎样才能做到这一点?
最佳答案
您可以只使用您的 VPS 的 ip 代替“sample.com”:
server {
listen 80;
server_name <your_ip_address>;
<other stuff>
}
如果您还没有,您可能想要分配一个静态 IP;我相信 Digital Ocean 会给你一些免费的。
关于linux - 测试没有域名的nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41751306/