我在Centos7上构建了一个基本的Django项目和应用程序,但无法从外部访问它。检查以下配置。
[root@pytoncentos7 myproject]# cat settings.py | grep ALLOWED
ALLOWED_HOSTS = ['*']
Run Code Online (Sandbox Code Playgroud)
然后按以下方式运行服务器。
[root@pytoncentos7 myproject]# python3.6 manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
May 24, 2018 - 15:03:04
Django version 2.0.5, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)
另外,防火墙没有运行
[root@pytoncentos7 myproject]# firewall-cmd --state
not running
Run Code Online (Sandbox Code Playgroud)
以下是我的端口列表。
[root@pytoncentos7 myproject]# netstat -lptun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 127.0.0.1:8000 0.0.0.0:* …Run Code Online (Sandbox Code Playgroud)