safely hosting a django project over apache using centos

Posted by tipu on Stack Overflow See other posts from Stack Overflow or by tipu
Published on 2010-05-24T03:39:12Z Indexed on 2010/05/24 4:01 UTC
Read the original article Hit count: 458

Filed under:
|
|

Error can be seen at: http://djaffry.selfip.com:8080/

I had a project working great, but I had all the files under /var/www/ and with my limited understanding it's bad, according to django's site:

"If your background is in PHP, you’re probably used to putting code under the Web server’s document root (in a place such as /var/www). With Django, you don’t do that. It’s not a good idea to put any of this Python code within your Web server’s document root, because it risks the possibility that people may be able to view your code over the Web. That’s not good for security.

Put your code in some directory outside of the document root, such as /home/mycode."

So I went to /home/tipu/stuff/ and executed django-admin.py startproject twingle. Then I went to apache and did

<VirtualHost *:8080>
    ServerName tweet_search_engine
    DocumentRoot /home/tipu/stuff/twingle/
</VirtualHost>

<Directory /home/tipu/stuff/twingle>
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE settings
  PythonOption django.root /home/tipu/stuff/twingle
  PythonDebug On
  PythonPath "['/home/tipu/stuff/', '/home/tipu/stuff/twingle/'] + sys.path"
</Directory>

Now I am getting a 403 Forbidden error.. any idea what I'm doing wrong? I'm newer to Linux (CentOS) and django, so I could be over looking some very simple things.

© Stack Overflow or respective owner

Related posts about django

Related posts about apache