0

Im using sqlite3 as a database to my project, it's working when i manually serve a temporary port by typing python manage.py runserver however the exception throws after deploying in apache server shown in figure below. at first i thought this is a file permission issue and when i ran commands in django e.g. python manage.py runserver, python manage.py mycommand, python manage.py createsuperuser the error not occur and working but when i use the designated port that i created in /etc/apache2/sites-enabled/000-default.conf the error comes. I am using ubuntu 20.04 and apache 2.4.41 as my environment and the virtual host configuration below is my port designate to my project.

Listen 112
<VirtualHost *:112>
    Alias /assets /home/yuan04/Projects/Lotto/assets
    <Directory /home/yuan04/Projects/Lotto/assets>
         Require all granted
    </Directory>
    <Directory /home/yuan04/Projects/Lotto/lotto>
        <Files wsgi.py>
            Require all granted
        </Files>
        <Files db.sqlite3>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess lotto python-home=/home/yuan04/Projects/Lotto/venv python-path=/home/yuan04/Projects/Lotto
    WSGIProcessGroup lotto
    WSGIScriptAlias / /home/yuan04/Projects/Lotto/lotto/wsgi.py
</VirtualHost>

django sqlite3 error

Mark Anthony Libres
  • 906
  • 1
  • 7
  • 14
  • Likely the user with which you run the webserver has no write privelleges to the file. Typically a webserver (on production) runs with another user with the smallest set of privelleges necessary to let the server work (sometimes named `www-data`). If the database thus does not provide write privelleges to the database file for that user, the database can be read-only. – Willem Van Onsem Jul 04 '21 at 16:48
  • @WillemVanOnsem, now i get it WSGIDaemonProcess has a parameter user=USERNAME but how i set for any users when parameter user is need to specify. it is supposed to be any user can access my project ? – Mark Anthony Libres Jul 04 '21 at 17:04
  • no, only the user that runs the webserver, you can try to let it render the outcome of `whoami`: https://stackoverflow.com/questions/860140/whoami-in-python – Willem Van Onsem Jul 04 '21 at 17:05

0 Answers0