简体   繁体   English

在云上部署Django应用程序,但甚至无法访问ip_address:8000

[英]Deploy Django Application on Cloud, but even cannot get access to ip_address:8000

I am a beginner on Django. 我是Django的初学者。 And try to deploy a testproject on cloud server to check if it works or not. 并尝试在云服务器上部署一个测试项目,以检查它是否有效。 Server: Ubuntu 16.04 伺服器:Ubuntu 16.04

And after I create virtualenv on the server with nginx installed. 在安装了Nginx的服务器上创建virtualenv之后。 I execute below: 我在下面执行:

python manage.py runserver 0.0.0.0:8000

And then I go to the browser to access my server's http://ip-address:8000 . 然后,我进入浏览器以访问服务器的http:// ip-address:8000 But it failed to show anything of my application. 但是它无法显示我的应用程序的任何内容。

I already added the ip-address to ALLOWED_HOST. 我已经将IP地址添加到ALLOWED_HOST。 But still not working. 但仍然无法正常工作。

Are there any thoughts for this situation? 对于这种情况有什么想法吗?

maybe this method work for you because it worked for mine on the ec2 instance on Amazon web server. 也许此方法对您有用,因为它在Amazon Web服务器上的ec2实例上适用于我的方法。

step1: go to your dashboard find launch-wizard menu and open it. 步骤1:转到仪表板,找到启动向导菜单,然后将其打开。

step2: Now click on inbound after that click on edit. 第二步:现在,单击入站,然后单击编辑。 Here click on Add rule and select Custom TCP rule & enter 8000 in port range. 在这里单击添加规则,然后选择自定义TCP规则,然后在端口范围内输入8000。 Now again click on Add rule and select HTTP and similarly do for HTTPS then click on save button. 现在再次单击“添加规则”并选择“ HTTP”,对HTTPS进行类似的操作,然后单击“保存”按钮。

step3: save and restart your AWS machine. 第三步:保存并重启您的AWS机器。 Hopefully, your Django app runs on 8000 port. 希望您的Django应用程序在8000端口上运行。

For a Linux instance in the security group, follow these steps to verify the security group rule: 对于安全组中的Linux实例,请按照以下步骤验证安全组规则:

  1. Connect to a Linux instance by using a password. 使用密码连接到Linux实例。
  2. Run the following command to check whether TCP 80 is being listened. 运行以下命令,检查是否正在侦听TCP 80。 netstat -an | grep 80

If the following result returns, web service for TCP port 80 is enabled. 如果返回以下结果,则启用TCP端口80的Web服务。

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN

If not then there is a problem with your security group setup, please go through the official documentation and see how you can fix it: https://www.alibabacloud.com/help/doc-detail/25471.htm 如果不是这样,则说明您的安全组设置存在问题,请仔细阅读官方文档,并查看如何解决此问题: https : //www.alibabacloud.com/help/doc-detail/25471.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM