我正在尝试使用apache2在Linux ubuntu服务器上部署我的Django项目。当我不使用虚拟设备时,我可以正确地部署它。我重建了我的VM,并做了同样的事情,但使用了虚拟环境,但它不起作用。
当我访问我的网站url时,它给我这个错误Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.
以下是我的/etc/apache2/ites-available/mysite.conf
<VirtualHost *:80>
ServerName MYIPSERVER
ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined
WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite/venv/lib/python3.10/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
Alias /robots.txt /var/www/mysite/static/robots.txt
Alias /favicon.ico /var/www/mysite/static/favicon.ico
Alias /static/ /var/www/mysite/static/
Alias /static/ /var/www/mysite/media/
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /var/www/mysite/static>
Require all granted
</Directory>
<Directory /var/www/mysite/media>
Require all granted
</Directory>
</VirtualHost>
在没有venv之前,WSGIDaemonProcess是这样设置的WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite
,但它不起作用,所以我将其更改为:WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite/venv/lib/python3.10/site-packages
但它仍然不起作用。我不确定问题是从哪里来的。我的项目文件夹位于/var/www
1条答案
按热度按时间qjp7pelc1#
您需要将
python-home
参数设置为包含Virtualenv的文件夹,并将python-path
参数设置为包含项目的文件夹。请参阅https://docs.djangoproject.com/en/stable/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode