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