I deployed my Django project on a Linux server using Linode. When I run it by the python manage.py runserver
command on port 8000 everything looks fine. However, when I use apache2 I get the following error when loading the website:
FileNotFoundError at /
[Errno 2] No such file or directory: 'research_files/data.xlsx'
Request Method: GET
Request URL: http://453.33.13.202/
Django Version: 3.1.5
Exception Type: FileNotFoundError
Exception Value:
[Errno 2] No such file or directory: 'research_files/data.xlsx'
In /etc/apache2/sites-available I've created a django_project.conf file which has the following instructions:
Alias /research_files/ /home/alexa/django_project/research_files/
<Directory /home/alexa/django_project/django_project/research_files>
Require all granted
</Directory>
<Directory /home/alexa/django_project/django_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/alexa/django_project/django_project/wsgi.py>
WSGIDaemonProcess django_app python-path=/home/alexa/django_project python-home=/home/alexa/django_project/venv
WSGIProcessGroup django_app
Then I've enabled that file by running sudo a2ensite django_project
and also given access to the folder by running:
sudo chown :www-data django_project/research_files
sudo chmod 664 django_project/research_files
What may be causing this error?