403 error trying to access main site - Django Apache Ubuntu

Viewed 16

I am learning Django and have been trying to follow the tutorial here: https://www.youtube.com/watch?v=Sa_kQheCnds&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p&index=14 This is a Python Django application which should run on Apache engine on Ubuntu on a Linode Server.

However I can't get the production to work. When I was on the step of running the app on Django server via 0.0.0.0:8000 port it worked, when I got to the point where according to video everything should work, via HTTP 80 port, it gives me 403 error saying "You don't have permission to access this resource"

I have looked through some similar posts, but they have not helped to solve my problem or I did not understand how should I apply the solution.

How can I check what causes this problem? What parts of code can I provide to help to solve it?

1 Answers

I solved it:

Here is the Apache 2 error:

[Sun Sep 11 06:50:44.649753 2022] [wsgi:warn] [pid 76958:tid 139964959332224] (13)Permission de>
Python path configuration:
  PYTHONHOME = '/home/<user>/<project name>/venv'
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/home/<user>/<project name>/venv'
  sys.base_exec_prefix = '/home/<user>/<project name>/venv'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/home/<user>/<project name>/venv'
  sys.exec_prefix = '/home/<user>/<project name>/venv'
  sys.path = [
    '/home/<user>/<project name>/venv/lib/python310.zip',
    '/home/<user>/<project name>/venv/lib/python3.10',
    '/home/<user>/<project name>/venv/lib/python3.10/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f4c21ae9780 (most recent call first):
  <no Python frame>

Following the error message, according to that post: https://www.linode.com/community/questions/22951/no-python-frame-error-while-trying-to-connect-to-apache-on-mod_wsgi-in-ubuntu

I have set 755 permissions on my project folder:

sudo chmod 755 /home/<user>

now I am getting another error, but at least the 403 initial error I posted here has been solved.

Related