[英]cannot acces http://server_domain_or_IP:8000
I am using an AzureVM to host my development API server written in django. There, I cloned my codebase and did all the requirements.txt installation.我正在使用 AzureVM 来托管我在 django 中编写的开发 API 服务器。在那里,我克隆了我的代码库并完成了所有 requirements.txt 安装。 Before executing the manage.py runserver 0.0.0.0:8000
command, I changed the firewall permission rule: sudo ufw allow 8000
.在执行manage.py runserver 0.0.0.0:8000
命令之前,我更改了防火墙权限规则: sudo ufw allow 8000
。 The sudo ufw status
commads shows the following result: sudo ufw status
commads 显示以下结果:
Status: active
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
8000 ALLOW Anywhere
OpenSSH ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
8000 (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
and then I run python3 manage.py runserver 0.0.0.0:8000
.然后我运行python3 manage.py runserver 0.0.0.0:8000
。
I should be able to see the default django page @ http://SERVER_IP_OR_DOMAIN:8000
But nothing shows.我应该能够看到默认的 django 页面 @ http://SERVER_IP_OR_DOMAIN:8000
但没有任何显示。 whereas if I hit http://SERVER_IP_OR_DOMAIN
, I can see the NGINX landing page.而如果我点击http://SERVER_IP_OR_DOMAIN
,我可以看到 NGINX 登陆页面。
I am following this blog from digital ocean .我正在关注来自数字海洋的这个博客。
Here is my VM.network rules:这是我的 VM.network 规则:
How can I fix this?我怎样才能解决这个问题?
I tried to reproduce the same in my environment and got the results like below:我尝试在我的环境中重现相同的内容并得到如下结果:
To resolve this issue:要解决此问题:
In your virtual machine make sure to Add inbound port Destination port ranges as 8000 like below:在您的虚拟机中,确保将入站端口目标端口范围添加为 8000 ,如下所示:
Workaround: installed nginx using sudo apt install nginx
解决方法:使用sudo apt install nginx
Install sudo apt-get install python3-venv
and create a virtual environment python3 -m venv /home/imran/env<nameof virtual enviroment>
and then ls
安装sudo apt-get install python3-venv
并创建虚拟环境python3 -m venv /home/imran/env<nameof virtual enviroment>
然后ls
Now, try to activate your virtual environment source ~/env/xyz/bin/activate
现在,尝试激活你的虚拟环境source ~/env/xyz/bin/activate
Install Django:安装 Django:
pip install Django
create a Django project which should be on your path by default.创建一个 Django 项目,默认情况下它应该在你的路径上。
django-admin.py startproject myproject
ls
cd myproject/
ls
Then vim myproject/setting.py
press insert key type your ip address in allowed_hosts like below然后vim myproject/setting.py
按插入键在 allowed_hosts 中键入您的 ip 地址,如下所示
Once you check with your *http://SERVER_IP:8000*
got result successfully一旦你检查你的*http://SERVER_IP:8000*
成功得到结果
To more in detail refer this link by tony要更详细地参考托尼的这个链接
Set Up Django on Nginx with uWSGI - Tony Teaches Tech使用 uWSGI 在 Nginx 上设置 Django - Tony Teaches Tech
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.