2017-06-15 3 views
0

Problem:django Entwicklungsserver funktionieren nicht

django Entwickler-Server ist das Welcome to Django Seite im Anschluss an diesen django tutorial nicht dienen.

Anweisungen befolgt:

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 

dann den Entwickler-Server ich den folgenden Befehl lief zu starten:

[email protected]:/mnt/web-server/mysite$ python3.5 manage.py runserver 8080 & 
[1] 1649 
[email protected]:/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 

Nach meinem Browser gehen und den Server auf http://192.168.1.165:8080/ ich zuzugreifen versuchen, kann es immer noch nicht zur Arbeit bringen.

Beobachtungen:

Wenn ich versuche, die üblichen Befehle der Port zu sehen, ob arbeitet das ist, was ich bekommen:

[email protected]:/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 
[email protected]:/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  -    
[email protected]:/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) 

Frage

Was mache ich falsch um zu verhindern, dass die statische Begrüßungsseite bedient wird?

OS Information:

[email protected]:/mnt/web-server/mysite$ hostname -I 
192.168.1.165 

[email protected]:/mnt/web-server/mysite$ python3 --version 
Python 3.5.2 

[email protected]:/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 

[email protected]:/mnt/web-server/mysite$ uname -r 
4.4.0-62-generic 

[email protected]:/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 
+1

Versuch 'python3.5 manage.py runserver 0.0.0.0: 8080' – Ykh

+0

Es ist nun nicht nur die Begrüßungsseite dient, erhalte ich eine Ausnahme ' DisallowedHost an/ Ungültige HTTP_HOST Header: '192.168.1.165:8080' . Möglicherweise müssen Sie ALLOWED_HOSTS "192.168.1.165" hinzufügen. Request-Methode: \t ' – Abraham

+1

hinzufügen' ALLOWED_HOSTS = ['192.168.1.165'] 'zu Ihrem' settings.py' – Ykh

Antwort

2

python3.5 manage.py runserver 0.0.0.0:8080 versuchen und settings.py

python3.5 manage.py runserver 0.0.0.0:8080 wird zuweisen django auf dem lokalen Computer die IP-Adresse ALLOW_HOSTS=['192.xxx.xxx.xxx'] zu Ihrem hinzufügen, können Sie Ihre django Zugriff mit http://localhost/ oder http://your_ip_address/

mit python3.5 manage.py runserver 8080 Django kann nur vonzugegriffen werden.

Verwandte Themen