Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5952

Permission Denied and Python Module Issues when Deploying Django with Apache on Ubuntu

$
0
0

I'm encountering difficulties while trying to deploy my Django website using Apache on an Ubuntu server. Here are the details of the problem:

Error Messages:

Current thread 0x00007e9faacab780 (most recent call first):<no Python frame>[Thu Jun 27 02:58:10.538441 2024] [wsgi:warn] [pid 16762:tid 139224230311808] (13)Permission denied: mod_wsgi (pid=16762): Unable to stat Python home /home/robch/TestSite/django_env. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.Python path configuration:PYTHONHOME = '/home/robch/TestSite/django_env'PYTHONPATH = (not set)
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encodingPython runtime state: core initializedModuleNotFoundError: No module named 'encodings'

and when i go to my page i see and error 403: screen of my page

here is some more information about my files:

(django_env) robch@django-server:~$ ls -latotal 44drwxr-x---  6 robch robch    4096 Jun 27 01:44 .drwxr-xr-x  3 root  root     4096 Jun 26 21:58 ..-rw-------  1 robch robch    1102 Jun 27 00:08 .bash_history-rw-r--r--  1 robch robch     220 Jun 26 21:58 .bash_logout-rw-r--r--  1 robch robch    3771 Jun 26 21:58 .bashrcdrwx------  3 robch robch    4096 Jun 26 23:45 .cache-rw-------  1 robch robch      20 Jun 27 01:44 .lesshstdrwxrwxr-x  3 robch robch    4096 Jun 26 22:21 .local-rw-r--r--  1 robch robch     807 Jun 26 21:58 .profiledrwx------  2 robch robch    4096 Jun 26 22:56 .ssh-rw-r--r--  1 robch robch       0 Jun 26 22:43 .sudo_as_admin_successfuldrwxrwxr-x 13 robch www-data 4096 Jun 27 02:51 TestSite(django_env) robch@django-server:~$ cd TestSite/ && ls -latotal 300drwxrwxr-x 13 robch    www-data   4096 Jun 27 02:51 .drwxr-x---  6 robch    robch      4096 Jun 27 01:44 ..drwxrwxr-x  8 robch    robch      4096 Jun 26 23:47 .git-rw-rw-r--  1 robch    robch         6 Jun 26 23:39 README.mddrwxrwxr-x  3 robch    robch      4096 Jun 27 02:23 Soundrisedrwxrwxr-x  5 robch    robch      4096 Jun 26 23:39 accountsdrwxrwxr-x  4 robch    robch      4096 Jun 26 23:39 beatmakersdrwxrwxr-x  5 robch    robch      4096 Jun 26 23:39 beatsdrwxrwxr-x  4 robch    robch      4096 Jun 26 23:39 content-rw-rw-r--  1 robch    www-data 241664 Jun 27 00:59 db.sqlite3drwxrwxr-x  5 www-data www-data   4096 Jun 27 02:51 django_envdrwxrwxr-x  5 robch    robch      4096 Jun 26 23:39 files-rw-rw-r--  1 robch    robch       665 Jun 26 23:39 manage.py-rw-rw-r--  1 robch    robch        80 Jun 26 23:47 requirements.txtdrwxr-xr-x  4 www-data www-data   4096 Jun 26 23:56 staticdrwxrwxr-x  4 robch    robch      4096 Jun 26 23:39 transactiondrwxrwxr-x  4 robch    robch      4096 Jun 26 23:39 utils(django_env) robch@django-server:~/TestSite$ cat /etc/apache2/sites-enabled/TestSite.conf<VirtualHost *:80>        # The ServerName directive sets the request scheme, hostname and port that        # the server uses to identify itself. This is used when creating        # redirection URLs. In the context of virtual hosts, the ServerName        # specifies what hostname must appear in the request's Host: header to        # match this virtual host. For the default virtual host (this file) this        # value is not decisive as it is used as a last resort host regardless.        # However, you must set it for any further virtual host explicitly.        ServerName 85.215.209.167        ServerAdmin webmaster@localhost        DocumentRoot /var/www/html        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,        # error, crit, alert, emerg.        # It is also possible to configure the loglevel for particular        # modules, e.g.        #LogLevel info ssl:warn        ErrorLog ${APACHE_LOG_DIR}/error.log        CustomLog ${APACHE_LOG_DIR}/access.log combined        # For most configuration files from conf-available/, which are        # enabled or disabled at a global level, it is possible to        # include a line for only one particular virtual host. For example the        # following line enables the CGI configuration for this host only        # after it has been globally disabled with "a2disconf".        #Include conf-available/serve-cgi-bin.conf        Alias /static /home/robch/TestSite/static<Directory /home/robch/TestSite/static>                Require all granted</Directory>        Alias /media /home/robch/TestSite/files/media<Directory /home/robch/TestSite/files/media>                Require all granted</Directory><Directory /home/robch/TestSite/Soundrise><Files wsgi.py>                        Require all granted</Files></Directory>        WSGIScriptAlias / /home/robch/TestSite/Soundrise/wsgi.py        WSGIDaemonProcess django_app python-home=/home/robch/TestSite/django_env python-path=/home/robch/TestSite        WSGIProcessGroup django_app</VirtualHost>(django_env) robch@django-server:~/TestSite$

Steps Taken:

Checked and adjusted permissions for /home/robch/TestSite/django_env.Verified Python installation within the virtual environment (/home/robch/TestSite/django_env).Reviewed Apache configuration (*.conf files in /etc/apache2/sites-available/) to ensure correct python-home and python-path directives.

Request for Assistance:

How can I have my site FINALLLY displaying.

What steps should I take to ensure Python within the virtual environment has all necessary modules, especially 'encodings'?


Viewing all articles
Browse latest Browse all 5952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>