django 开发服务器不工作 [英] django development server not working
问题描述
问题:
django 开发人员服务器没有在此 django 教程之后提供欢迎使用 Django 页面.
django developer server is not serving the Welcome to Django page following this django tutorial.
遵循的说明:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3.5 get-pip.py
sudo apt-get install libmysqlclient-dev mysqlclient build-essential python3-dev -y
sudo -H python3.5 -m pip install mysqlclient
sudo -H python3.5 -m pip install Django
cd /mnt/web-server/
django-admin startproject mysite
cd mysite
然后为了启动开发者服务器,我运行了以下命令:
Then to start up the developer server I ran the following command:
webuser@web-server:/mnt/web-server/mysite$ python3.5 manage.py runserver 8080 &
[1] 1649
webuser@web-server:/mnt/web-server/mysite$ Performing system checks...
System check identified no issues (0 silenced).
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
June 15, 2017 - 02:52:22
Django version 1.11.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CONTROL-C.
^M
在我的浏览器中尝试访问 http://192.168.1.165:8080/
上的服务器后,我仍然无法让它工作.
After going to my browser and trying to access the server on http://192.168.1.165:8080/
I still cannot get it to work.
观察:
当我尝试使用常用命令查看端口是否正常工作时,我得到的是:
When I try the usual commands to see if the port is working this is what I get:
webuser@web-server:/mnt/web-server/mysite$ netstat -nlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
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:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 1651/python3.5
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 17605 1471/systemd /run/user/1000/systemd/private
unix 2 [ ACC ] SEQPACKET LISTENING 10427 - /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 13885 - /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 10168 - /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 10173 - /run/lvm/lvmetad.socket
unix 2 [ ACC ] STREAM LISTENING 10174 - /run/systemd/fsck.progress
unix 2 [ ACC ] STREAM LISTENING 10176 - /run/lvm/lvmpolld.socket
unix 2 [ ACC ] STREAM LISTENING 13887 - /var/lib/lxd/unix.socket
unix 2 [ ACC ] STREAM LISTENING 10180 - /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 13886 - /run/uuidd/request
unix 2 [ ACC ] STREAM LISTENING 13888 - /run/snapd.socket
unix 2 [ ACC ] STREAM LISTENING 13889 - /run/snapd-snap.socket
unix 2 [ ACC ] STREAM LISTENING 13892 - /run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 17257 - /var/run/mysqld/mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 15992 - @ISCSIADM_ABSTRACT_NAMESPACE
webuser@web-server:/mnt/web-server/mysite$ netstat -tulep
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 localhost:mysql *:* LISTEN mysql 17256 -
tcp 0 0 localhost:http-alt *:* LISTEN webuser 18667 1651/python3.5
tcp 0 0 *:ssh *:* LISTEN root 17212 -
tcp6 0 0 [::]:ssh [::]:* LISTEN root 17214 -
udp 0 0 *:bootpc *:* root 14154 -
webuser@web-server:/mnt/web-server/mysite$ lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python3.5 1651 webuser 4u IPv4 18667 0t0 TCP localhost:http-alt (LISTEN)
问题
我在阻止提供静态欢迎页面方面做错了什么?
What am I doing wrong in preventing the static welcome page to be served?
操作系统信息:
webuser@web-server:/mnt/web-server/mysite$ hostname -I
192.168.1.165
webuser@web-server:/mnt/web-server/mysite$ python3 --version
Python 3.5.2
webuser@web-server:/mnt/web-server/mysite$ python3 -m pip list --format freeze
chardet==2.3.0
command-not-found==0.3
Django==1.11.2
language-selector==0.1
mysqlclient==1.3.10
pip==9.0.1
pycurl==7.43.0
pygobject==3.20.0
python-apt==1.1.0b1
python-debian==0.1.27
python-systemd==231
pytz==2017.2
requests==2.9.1
setuptools==36.0.1
six==1.10.0
ssh-import-id==5.5
ufw==0.35
unattended-upgrades==0.1
urllib3==1.13.1
virtualenv==15.1.0
wheel==0.29.0
webuser@web-server:/mnt/web-server/mysite$ uname -r
4.4.0-62-generic
webuser@web-server:/mnt/web-server/mysite$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
推荐答案
try python3.5 manage.py runserver 0.0.0.0:8080
并添加 ALLOW_HOSTS=['192.xxx.xxx.xxx']
到您的 settings.py
try python3.5 manage.py runserver 0.0.0.0:8080
and add ALLOW_HOSTS=['192.xxx.xxx.xxx']
to your settings.py
python3.5 manage.py runserver 0.0.0.0:8080
将 django 分配给您本地计算机的 IP 地址,您可以使用 http://localhost/
访问 django或 http://your_ip_address/
python3.5 manage.py runserver 0.0.0.0:8080
will assign django to your local computer ip address,your can access django with http://localhost/
or http://your_ip_address/
with python3.5 manage.py runserver 8080
django 只能通过 http://localhost/
访问.
with python3.5 manage.py runserver 8080
django only can be access by http://localhost/
.
这篇关于django 开发服务器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!