我一直被困在django apache部署中。当我尝试使用linode()部署我的网页并访问它时,我的网站一直显示这500个内部服务器错误。这发生在我在我的静脉壳里运行这个之后。
$ sudo service apache2 restart

因为网页建议我查看日志文件,所以我发现我有mod wsgi问题。这是我的日志文件。
[Fri Feb 14 06:43:49.388284 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] mod_wsgi (pid=26679): Target WSGI script '/home/harryghgim/django_project/django_project/wsgi.py' cannot be loaded as Python module.
[Fri Feb 14 06:43:49.388369 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] mod_wsgi (pid=26679): Exception occurred processing WSGI script '/home/harryghgim/django_project/django_project/wsgi.py'.
[Fri Feb 14 06:43:49.388622 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] Traceback (most recent call last):
[Fri Feb 14 06:43:49.388720 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/django_project/wsgi.py", line 16, in <module>
[Fri Feb 14 06:43:49.388726 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] application = get_wsgi_application()
[Fri Feb 14 06:43:49.388734 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/venv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Feb 14 06:43:49.388739 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] django.setup(set_prefix=False)
[Fri Feb 14 06:43:49.388745 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/venv/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Fri Feb 14 06:43:49.388750 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Fri Feb 14 06:43:49.388757 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
[Fri Feb 14 06:43:49.388760 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] self._setup(name)
[Fri Feb 14 06:43:49.388766 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
[Fri Feb 14 06:43:49.388770 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] self._wrapped = Settings(settings_module)
[Fri Feb 14 06:43:49.388777 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
[Fri Feb 14 06:43:49.388781 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] mod = importlib.import_module(self.SETTINGS_MODULE)
[Fri Feb 14 06:43:49.388787 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Feb 14 06:43:49.388790 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Feb 14 06:43:49.388813 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Feb 14 06:43:49.388820 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Feb 14 06:43:49.388826 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Fri Feb 14 06:43:49.388832 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Fri Feb 14 06:43:49.388837 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap_external>", line 678, in exec_module
[Fri Feb 14 06:43:49.388843 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Fri Feb 14 06:43:49.388850 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/home/harryghgim/django_project/django_project/settings.py", line 17, in <module>
[Fri Feb 14 06:43:49.388853 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] config = json.load(config_file)
[Fri Feb 14 06:43:49.388859 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/usr/lib/python3.6/json/__init__.py", line 299, in load
[Fri Feb 14 06:43:49.388862 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
[Fri Feb 14 06:43:49.388867 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
[Fri Feb 14 06:43:49.388871 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] return _default_decoder.decode(s)
[Fri Feb 14 06:43:49.388876 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
[Fri Feb 14 06:43:49.388879 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] obj, end = self.raw_decode(s, idx=_w(s, 0).end())
[Fri Feb 14 06:43:49.388886 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
[Fri Feb 14 06:43:49.388889 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] obj, end = self.scan_once(s, idx)
[Fri Feb 14 06:43:49.388909 2020] [wsgi:error] [pid 26679:tid 140324755478272] [remote 121.131.97.11:51035] json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 5 column 1 (char 129)很抱歉有这么长的日志文件。有人能告诉我怎么解决这个问题吗?
编辑
这是我在/home/harryghgim/django_project/django_project/wsgi.py的wsgi.py文件
""" WSGI config for django_project project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ """
import os from django.core.wsgi
import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings')
application = get_wsgi_application()这是我在/etc/apache2/sites-available/django_project.conf的虚拟主机设置
Alias /static /home/harryghgim/django_project/static
<Directory /home/harryghgim/django_project/static>
Require all granted
</Directory>
Alias /media /home/harryghgim/django_project/media
<Directory /home/harryghgim/django_project/media>
Require all granted
</Directory>
<Directory /home/harryghgim/django_project/django_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/harryghgim/django_project/django_project/wsgi.py
WSGIDaemonProcess django_app python-path=/home/harryghgim/django_project python-home=/home/harryghgim/django_project/venv
WSGIProcessGroup django_app我应该改变其中任何一个来解决这个问题吗?
编辑#2
由于它给我带来了巨大的痛苦,所以我决定运行另一个用户名和服务器名称略有不同的linux服务器。而且我也有同样的问题。这一次我要把它整理整齐。
[Sat Feb 15 06:55:00.657722 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] mod_wsgi (pid=3546): Failed to exec Python script file '/home/djtu/django_project/django_project/wsgi.py'.
[Sat Feb 15 06:55:00.658894 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] mod_wsgi (pid=3546): Exception occurred processing WSGI script '/home/djtu/django_project/django_project/wsgi.py'.
[Sat Feb 15 06:55:00.659151 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] Traceback (most recent call last):
[Sat Feb 15 06:55:00.659254 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/django_project/wsgi.py", line 16, in <module>
[Sat Feb 15 06:55:00.659291 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] application = get_wsgi_application()
[Sat Feb 15 06:55:00.659319 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Sat Feb 15 06:55:00.659324 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] django.setup(set_prefix=False)
[Sat Feb 15 06:55:00.659331 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
[Sat Feb 15 06:55:00.659335 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Sat Feb 15 06:55:00.659341 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
[Sat Feb 15 06:55:00.659346 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] self._setup(name)
[Sat Feb 15 06:55:00.659351 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
[Sat Feb 15 06:55:00.659355 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] self._wrapped = Settings(settings_module)
[Sat Feb 15 06:55:00.659361 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
[Sat Feb 15 06:55:00.659365 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] mod = importlib.import_module(self.SETTINGS_MODULE)
[Sat Feb 15 06:55:00.659371 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Sat Feb 15 06:55:00.659375 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] return _bootstrap._gcd_import(name[level:], package, level)
[Sat Feb 15 06:55:00.659392 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Sat Feb 15 06:55:00.659398 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Sat Feb 15 06:55:00.659404 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
[Sat Feb 15 06:55:00.659409 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
[Sat Feb 15 06:55:00.659415 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap_external>", line 728, in exec_module
[Sat Feb 15 06:55:00.659420 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Sat Feb 15 06:55:00.659426 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/home/djtu/django_project/django_project/settings.py", line 17, in <module>
[Sat Feb 15 06:55:00.659430 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] config = json.load(config_file)
[Sat Feb 15 06:55:00.659435 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/usr/lib/python3.7/json/__init__.py", line 296, in load
[Sat Feb 15 06:55:00.659439 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
[Sat Feb 15 06:55:00.659444 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
[Sat Feb 15 06:55:00.659448 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] return _default_decoder.decode(s)
[Sat Feb 15 06:55:00.659453 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
[Sat Feb 15 06:55:00.659457 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] obj, end = self.raw_decode(s, idx=_w(s, 0).end())
[Sat Feb 15 06:55:00.659462 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode
[Sat Feb 15 06:55:00.659466 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] obj, end = self.scan_once(s, idx)
[Sat Feb 15 06:55:00.659484 2020] [wsgi:error] [pid 3546:tid 140028878067456] [remote 121.131.97.11:50046] json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 6 column 1 (char 130)
[Sat Feb 15 06:55:00.850305 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] mod_wsgi (pid=3546): Failed to exec Python script file '/home/djtu/django_project/django_project/wsgi.py'.
[Sat Feb 15 06:55:00.850350 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] mod_wsgi (pid=3546): Exception occurred processing WSGI script '/home/djtu/django_project/django_project/wsgi.py'.
[Sat Feb 15 06:55:00.850563 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] Traceback (most recent call last):
[Sat Feb 15 06:55:00.850634 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/django_project/wsgi.py", line 16, in <module>
[Sat Feb 15 06:55:00.850639 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] application = get_wsgi_application()
[Sat Feb 15 06:55:00.850646 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Sat Feb 15 06:55:00.850663 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] django.setup(set_prefix=False)
[Sat Feb 15 06:55:00.850683 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
[Sat Feb 15 06:55:00.850687 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Sat Feb 15 06:55:00.850693 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
[Sat Feb 15 06:55:00.850697 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] self._setup(name)
[Sat Feb 15 06:55:00.850702 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
[Sat Feb 15 06:55:00.850706 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] self._wrapped = Settings(settings_module)
[Sat Feb 15 06:55:00.850711 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
[Sat Feb 15 06:55:00.850715 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] mod = importlib.import_module(self.SETTINGS_MODULE)
[Sat Feb 15 06:55:00.850721 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Sat Feb 15 06:55:00.850724 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] return _bootstrap._gcd_import(name[level:], package, level)
[Sat Feb 15 06:55:00.850730 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Sat Feb 15 06:55:00.850735 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Sat Feb 15 06:55:00.850741 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
[Sat Feb 15 06:55:00.850747 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
[Sat Feb 15 06:55:00.850752 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap_external>", line 728, in exec_module
[Sat Feb 15 06:55:00.850758 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Sat Feb 15 06:55:00.850763 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/home/djtu/django_project/django_project/settings.py", line 17, in <module>
[Sat Feb 15 06:55:00.850767 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] config = json.load(config_file)
[Sat Feb 15 06:55:00.850772 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/usr/lib/python3.7/json/__init__.py", line 296, in load
[Sat Feb 15 06:55:00.850776 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
[Sat Feb 15 06:55:00.850781 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
[Sat Feb 15 06:55:00.850785 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] return _default_decoder.decode(s)
[Sat Feb 15 06:55:00.850794 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
[Sat Feb 15 06:55:00.850798 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] obj, end = self.raw_decode(s, idx=_w(s, 0).end())
[Sat Feb 15 06:55:00.850803 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode
[Sat Feb 15 06:55:00.850807 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] obj, end = self.scan_once(s, idx)
[Sat Feb 15 06:55:00.850824 2020] [wsgi:error] [pid 3546:tid 140028760569600] [remote 121.131.97.11:50045] json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 6 column 1 (char 130)我检查了项目文件夹权限和www-data之类的东西。这是我的密码。
djtu@dj-serv:~/django_project$ ls -la
total 228
drwxr-xr-x 8 djtu www-data 4096 Feb 15 06:13 .
drwxr-xr-x 7 djtu djtu 4096 Feb 15 06:55 ..
-rw-r--r-- 1 djtu djtu 6148 Feb 15 05:56 .DS_Store
drwxr-xr-x 6 djtu djtu 4096 Feb 15 05:56 blog
-rw-rw-r-- 1 djtu www-data 167936 Feb 15 06:13 db.sqlite3
drwxr-xr-x 3 djtu djtu 4096 Feb 15 06:48 django_project
-rw-r--r-- 1 djtu djtu 634 Feb 15 05:56 manage.py
drwxrwxr-x 3 djtu www-data 4096 Feb 15 05:56 media
-rw-r--r-- 1 djtu djtu 13994 Feb 15 05:56 posts.json
-rw-r--r-- 1 djtu djtu 624 Feb 15 05:56 requirements.txt
drwxrwxr-x 4 djtu djtu 4096 Feb 15 06:08 static
drwxr-xr-x 5 djtu djtu 4096 Feb 15 05:56 users
drwxrwxr-x 6 djtu djtu 4096 Feb 15 06:00 venv我还检查了启用了mod_wsgi。这是截图:

以防万一,我也在放置manage.py文件,以查看该文件是否有任何混乱或其他问题。
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()另外,我在我的项目文件夹中做了python manage.py check,如下所示。
(venv) djtu@dj-serv:~/django_project$ python manage.py check
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/djtu/django_project/django_project/settings.py", line 17, in <module>
config = json.load(config_file)
File "/usr/lib/python3.7/json/__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 6 column 1 (char 130)以下是我的机器信息: Apache/2.4.41 (Ubuntu 19.10),用于服务器和虚拟主机Python 3.7.5和Django 3.0.2
发布于 2020-07-31 02:28:27
我搞砸了json文件格式。我不应该把逗号放在数据的末尾。相反这个,
{"key1":"value1", "key2":"value2", "key3":"value3",}我设定如下。
{"key1":"value1", "key2":"value2", "key3":"value3"}而且效果很好。
https://stackoverflow.com/questions/60221673
复制相似问题