views:

30

answers:

2

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.

A: 

Well, under /home is not the right place, thanks to SELinux. Put the app under /srv instead.

Ignacio Vazquez-Abrams
+1  A: 

This is almost certainly just an access rights issue. The Apache user needs rights to access all the directories in the path to your project - home, home/tipu, home/tipu/stuff, home/tipu/stuff/twingle, and so on. You'll need to find out what user Apache is running as, and grant read rights to those directories.

As Ignacio suggests, /srv is probably a better place to put this - but the same rights issues still apply.

Daniel Roseman