title: how to run gunicorn with django as non-root
body: <p>I have a django application and I use gunicorn to run it. My script to start gunicorn looks like this:  </p>
  
  <pre><code>django_path=/path/to/your/manage.py 
  settingsfile=my_name  
  workers=2 
  
  cd $django_path
  exec gunicorn --env DJANGO_SETTINGS_MODULE=app.$settingsfile app.wsgi --workers=$workers &amp;
  </code></pre>
  
  <p>this works when I execute it. However, when I look at my database in my projectfolder <code>(cd /path/to/your/manage.py &amp;&amp; ll)</code> I get this: </p>
  
  <p><code>-rw-r--r-- 1 root   root    55K Dec  2 13:33 db.sqlite3</code></p>
  
  <p>Which means I need root permisson to do anyhting on the databse (for example do a <code>createuser</code>). So I looked around on Stackoverflow and tried a couple of things: </p>
  
  <ul>
  <li>I had the whole script at the top of  <code>/etc/init.d/rc.local</code></li>
  <li>Then I put the script as a script file <code>gunicorn_script.sh</code> put in <code>/etc/init.d</code>, did a <code>/usr/sbin/update-rc.d -f gunicorn_script.sh defaults</code></li>
  <li>Lastly, I tried to put this command at the top of the <code>rc.local</code> file: <code>su debian -c '/etc/init.d/gunicorn_script.sh start'</code> to execute the gunicorn_script as a debian user </li>
  </ul>
  
  <p>All of them started my app but the problem with the database remains (only root rights).  </p>
  
  <p>So how do I run that script as a non root user? </p>