[FASTCGI] Can not get Apache2, fastcgi, and django working
Andre Mikulec
andre_mikulec at hotmail.com
Wed Oct 28 12:05:16 EDT 2009
Hi,
I am having difficulty getting fastcgi on apache 2 working on my a centos 5.3 computer.
I have been trying to get this to work for 21 days.
May I have help?
------
I do the following.
service httpd restart
[root at localhost mysite]# ./manage.py runfcgi method=threaded
host=127.0.0.1 port=8000
<this returns immediately>
Next, I browse to http://127.0.0.1:8000
I get back the message.
Failed to Connect
Firefox can't establish a connection to the server at 127.0.0.1:8000.
This page seems to be continuously loading forever.
The loading icon keeps going around in a circle.
Next, I try the following.
service httpd restart
[root at localhost mysite]# ./manage.py runfcgi method=threaded
host=127.0.0.1 port=3000
<this returns immediately>
http://127.0.0.1:3000/
I get back a blank page.
This page seems to be continuously loading forever.
The loading icon keeps going around in a circle.
------
My /etc/httpd/conf/httpd.conf
file has the default follow entry.
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf
------
My ~/django.fcgi
file has the default follow entry.
#!/usr/bin/python
import sys, os
# Add a custom path
sys.path.insert(0,'/usr/bin/python')
# Switch to the directory of your project. (Optional)
os.chdir('/root/Django_Projects/mysite')
# OK
sys.path.insert(0,'/root/Django-1.1')
sys.path.insert(0,'/root/Django_Projects')
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.handlers.fastcgi import runfastcgi
runfastcgi(method='threaded', daemonize='false')
------
My /etc/httpd/conf.d/mod_fastcgi.conf
file has the following entry.
LoadModule fastcgi_module modules/mod_fastcgi.so
FastCGIExternalServer /root/django.fcgi -host 127.0.0.1:8000
<VirtualHost *:8000>
ServerName dummy
DocumentRoot /root/Django_Projects
Alias /media /root/Django_Projects_Media
RewriteEngine On
RewriteRule ^/(Django_Projects_Media.*)$ /$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /django.fcgi/$1 [QSA,L]
</VirtualHost>
------
My /root/.htaccess
file looks like the following.
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ django.fcgi/$1 [QSA,L]
------
My /root/Django_Projects/mysite directory looks like the following.
This is brand new. This has just been created.
[root at localhost mysite]# pwd
/root/Django_Projects/mysite
[root at localhost mysite]# ls -al
total 32
drwxr-xr-x 2 root root 4096 Oct 17 12:53 .
drwxr-xr-x 3 root root 4096 Oct 17 12:57 ..
lrwxrwxrwx 1 root root 43 Jun 20 2005 adminmedia -> /root/
Django-1.1/django/contrib/admin/media
-rwxr-xr-x 1 root root 0 Jun 20 2005 __init__.py
-rw-r--r-- 1 root root 120 Jun 20 2005 __init__.pyc
-rwxr-xr-x 1 root root 546 Jun 20 2005 manage.py
-rwxr-xr-x 1 root root 2773 Jun 20 2005 settings.py
-rw-r--r-- 1 root root 1747 Jun 20 2005 settings.pyc
-rwxr-xr-x 1 root root 542 Jun 20 2005 urls.py
-rw-r--r-- 1 root root 217 Jun 20 2005 urls.pyc
[root at localhost mysite]#
------
My home directory /root looks like the following.
[root at localhost ~]# pwd
/root
[root at localhost ~]# ls -alrt
total 504
drwxr-xr-x 8 root root 4096 Jul 29 00:59 Django-1.1
drwxr-xr-x 2 root root 4096 Oct 5 10:32 Django_Projects_Media
-rw-r--r-- 1 root root 128 Oct 5 11:24 .htaccess
-rwxr-xr-x 1 root root 491 Oct 17 12:31 django.fcgi
drwxr-xr-x 3 root root 4096 Oct 17 12:57 Django_Projects
[root at localhost ~]#
------
My (root) ~/.bash_profilee file looks like the following.
PATH=$PATH:$HOME/bin:/root/Django-1.1/django/bin
export PATH
unset USERNAME
PYTHONPATH=$HOME/Django_Projects
export PYTHONPATH
------
Thank you for some help,
Andre_Mikulec at Hotmail.com
Thank you.
Sincerely,
Andre Mikulec
Andre_Mikulec at Hotmail.com
_________________________________________________________________
Windows 7: It works the way you want. Learn more.
http://www.microsoft.com/Windows/windows-7/default.aspx?ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen2:102009
More information about the FastCGI-developers
mailing list