我很难让我的Django内容出现在我的网络浏览器上。如果我使用python3 manage.py runserver 192.168.0.10:8000
,我可以看到Django安装和管理页面,但我希望看到它而不指定端口号,我知道使用运行服务器是开发方面,而不是部署。另外值得注意的是我没有使用任何形式的VirtualEnv,因为这是一个专用的Pi / Project,我对库,本地python安装,虚拟python安装等感到困惑。
我的Django / MySQL / Apache2是最新的(据我所知)并且正确的db / table中有Django数据。
导航到192.168.0.10/或192.168.0.10/admin时,我没有错误页面或默认的apache页面。它坐在那里大约5分钟,然后给我“找不到页面”。
试图缩小范围,我想我有三个问题之一:
我不久前发布过一个类似的问题,我已经重新审视了这个问题以及它附带的链接,但它没有帮助。我确实安装了PHP和VirtualEnv,这是一个全新安装,没有。我希望有php安装有一些gui来管理我应该需要的MySQL,所以我可能会在发布之后再看看它是否有帮助。
Django的settings.py :我将提供重要的内容:
DEBUG = True
ALLOWED_HOSTS = ['192.168.0.10', '127.0.0.1']
.....
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'init_command': 'SET sql_mode=`STRICT_TRANS_TABLES`',
'read_default_file': '/etc/mysql/my.cnf',
},
}
}
......
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MySQL / my.cnf =
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# Import all .cnf files from configuration directory
#!includedir /etc/mysql/conf.d/
#!includedir /etc/mysql/mariadb.conf.d/
[client]
database = blog_data
host = localhost
user = root
password = xxx
default-character-set = utf8
#SET sql_mode='STRICT_TRANS_TABLES'
/etc/apache2/sites-available/000-default.conf =
...
Alias /static /home/pi/test_blog_app/blog/static
<Directory /home/pi/test_blog_app/blog/static>
Require all granted
</Directory>
<Directory /home/pi/test_blog_app/blog/blog>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess testblogapp python-path=/home/pi/test_blog_app python-home=/usr/lib/python3/dist-packages
WSGIProcessGroup testblogapp
WSGIScriptAlias / /home/pi/test_blog_app/blog/blog/wsgi.py
输出sudo nano var / log / apache2 / error.log(最后几行)=
Current thread 0xb6fa8e40 (most recent call first):
[Sun Oct 01 16:11:20.397787 2017] [core:notice] [pid 2390:tid 3069873728] AH00052: child pid 2476 exit signal Aborted (6)
[Sun Oct 01 16:11:20.398262 2017] [core:notice] [pid 2390:tid 3069873728] AH00052: child pid 2477 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0xb6fa8e40 (most recent call first):
版本
O / S - Raspbian 9.1
阿帕奇 - 2.4.25
Django - 1.11.5
Python - 3.5.3
MySQL - (Maria)10.1.23-MariaDB-9 + deb9u1 Raspbian 9.0
PHP - 7.0.19-1
编辑我试图使用重新安装mod_wsgi
sudo apt-get purge --auto-remove libapache2-mod-wsgi-py3
&amp;
sudo apt-get install libapache2-mod-wsgi-py3
但是,没有结果