您的位置:首页 > 运维架构 > 网站架构

搭建django网站,局域网内其他主机无法访问问题

2016-03-28 21:20 756 查看
1.打开django网站服务器

python manage.py runserver 192.168.1.115:8000

[root@localhost test]# python manage.py runserver 192.168.1.115:8000
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

March 28, 2016 - 13:11:57
Django version 1.9.4, using settings 'django_zll.settings'
Starting development server at http://192.168.1.115:8000/ Quit the server with CONTROL-C.


2.在局域网中另外一个pc访问网址,访问失败



3.这很有可能是因为服务器开启防火墙导致,检查服务器是否开启防火墙

[root@localhost Python-2.7.3]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination


发现开启了防火墙,执行下面命令关闭防火墙后就可以正常访问网址了

service iptables stop


ps:

防火墙相关服务开启命令如下:

CentOS Linux开启和关闭防火墙命令有两种,一种是临时的,重启即复原;另外一种是永久性的,重启不会复原。

1) 临时生效,重启后复原

开启: service iptables start

关闭: service iptables stop

2) 永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: