我正在尝试在VPS上部署一个网站。在这之前,我遇到了python版本的问题。问题是我不能安装最新的Django版本。我联系了技术支持,他们将python版本更新到了3.7。设置模块安装后,我使用venv在端口8000上进行了一些测试,应用程序正常运行。测试后,我设置了Apache2。现在显示500个内部服务器错误我认为这是python版本错误
如果你能帮助我,我将非常感激和高兴。请随时问我任何问题
操作系统:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.7 LTS
Release: 16.04
Codename: xenial
Apache2错误日志
sudo tail -f /var/log/apache2/error.log
[Tue Dec 08 13:06:27.538704 2020] [wsgi:error] [pid 31545:tid 139919710709504] [remote] Traceback (most recent call last):
[Tue Dec 08 13:06:27.538766 2020] [wsgi:error] [pid 31545:tid 139919710709504] [remote] File "/home/alpcusta/exampleproject/exampleproject/wsgi.py", line 3, in <module>
[Tue Dec 08 13:06:27.538791 2020] [wsgi:error] [pid 31545:tid 139919710709504] [remote] from django.core.wsgi import get_wsgi_application
[Tue Dec 08 13:06:27.538849 2020] [wsgi:error] [pid 31545:tid 139919710709504] [remote] ImportError: No module named 'django'
[Tue Dec 08 13:07:28.424966 2020] [mpm_event:notice] [pid 24199:tid 139919823435648] AH00493: SIGUSR1 received. Doing graceful restart
[Tue Dec 08 13:07:28.531474 2020] [mpm_event:notice] [pid 24199:tid 139919823435648] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Tue Dec 08 13:07:28.531511 2020] [core:notice] [pid 24199:tid 139919823435648] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 08 13:07:28.834420 2020] [mpm_event:notice] [pid 24199:tid 139919823435648] AH00493: SIGUSR1 received. Doing graceful restart
[Tue Dec 08 13:07:28.889875 2020] [mpm_event:notice] [pid 24199:tid 139919823435648] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Tue Dec 08 13:07:28.889910 2020] [core:notice] [pid 24199:tid 139919823435648] AH00094: Command line: '/usr/sbin/apache2'
apache2ctl configtest
Syntax OK
Python版本:
python3 --version
Python 3.7.9
python --version
Python 2.7.12
我确实运行了这些文件权限代码
sudo chown :www-data exampleproject/db.sqlite3
sudo chmod 664 exampleproject/db.sqlite3
sudo chown :www-data exampleproject
sudo chmod 775 exampleproject
sudo chown -R :www-data exampleproject/media/
sudo chmod -R 775 exampleproject/media
Conf文件:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/alpcusta/exampleproject/staticfiles
<Directory /home/alpcusta/exampleproject/staticfiles>
Require all granted
</Directory>
Alias /media /home/alpcusta/exampleproject/media
<Directory /home/alpcusta/exampleproject/media>
Require all granted
</Directory>
<Directory /home/alpcusta/exampleproject/exampleproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/alpcusta/exampleproject/exampleproject/wsgi.py
WSGIDaemonProcess dirican_app python-path=/home/alpcusta/exampleproject/python-home=/home/alpcusta/venv
WSGIProcessGroup dirican_app
</VirtualHost>
wsgi文件:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'exampleproject.settings')
application = get_wsgi_application()
已安装的模块
(venv) alpcusta@example:~$ pip freeze
asgiref==3.3.1
Django==3.1.3
django-cleanup==5.1.0
Pillow==8.0.1
pytz==2020.4
sqlparse==0.4.1
我确实尝试了以下步骤: 卸载django并重新安装
删除venv文件夹并卸载venv,然后使用requirement.txt文件安装venv
$ sudo apt-get remove python3-venv
$ sudo apt-get install python3.7-venv
$ python3.7 -m venv venv
$ pip install -r requirements.txt
同样的错误还在重复
目前没有回答
相关问题 更多 >
编程相关推荐