Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

pcrutch

So I run the dev server for my project and everything comes up fine,
map shows properly and loads the data correctly. However, using wsgi
the map loads and gives " Unhandled request return Internal Server
Error" and I checked the log file and I have the " premature end of
script headers" error. I have no clue why it won't load the data on
the map properly.

here is my sites-available file
----

   <VirtualHost *:8080>
        ServerName dragonfly.cens.ucla.edu

        WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
        WSGIProcessGroup dragonfly.cens.ucla.edu

        WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
        <Directory /home/patrick/geodj/>
            Order deny,allow
            Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
    </VirtualHost>

-----
sites-enabled file

<VirtualHost *:8080>
    #Basic setup
    ServerAdmin [hidden email]
    ServerName dragonfly.cens.ucla.edu
    ServerAlias dragonfly.cens.ucla.edu

    <Directory /home/patrick/geodj/>
        Order deny,allow
        Allow from all
    </Directory>

    LogLevel warn
    ErrorLog  /home/patrick/geodj/apache_error.log
    CustomLog /home/patrick/geodj/apache_access.log combined

    WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
    WSGIProcessGroup dragonfly.cens.ucla.edu

    WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
</VirtualHost>

-----
my project .wsgi file

import os, sys
sys.path.append('/home/patrick/geodj')
sys.path.append('/home/patrick/geodj/templates')


os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

What gives?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

Graham Dumpleton-2



On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:

> So I run the dev server for my project and everything comes up fine,
> map shows properly and loads the data correctly. However, using wsgi
> the map loads and gives " Unhandled request return Internal Server
> Error" and I checked the log file and I have the " premature end of
> script headers" error. I have no clue why it won't load the data on
> the map properly.
>
> here is my sites-available file
> ----
>
>    <VirtualHost *:8080>
>         ServerName dragonfly.cens.ucla.edu
>
>         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
>         WSGIProcessGroup dragonfly.cens.ucla.edu
>
>         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
>         <Directory /home/patrick/geodj/>
>             Order deny,allow
>             Allow from all
>         </Directory>
>
>         ErrorLog /var/log/apache2/error.log
>         LogLevel warn
>
>         CustomLog /var/log/apache2/access.log combined
>     </VirtualHost>
>
> -----
> sites-enabled file
>
> <VirtualHost *:8080>
>     #Basic setup
>     ServerAdmin [hidden email]
>     ServerName dragonfly.cens.ucla.edu
>     ServerAlias dragonfly.cens.ucla.edu
>
>     <Directory /home/patrick/geodj/>
>         Order deny,allow
>         Allow from all
>     </Directory>
>
>     LogLevel warn
>     ErrorLog  /home/patrick/geodj/apache_error.log
>     CustomLog /home/patrick/geodj/apache_access.log combined
>
>     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
>     WSGIProcessGroup dragonfly.cens.ucla.edu
>
>     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> </VirtualHost>
>
> -----
> my project .wsgi file
>
> import os, sys
> sys.path.append('/home/patrick/geodj')
> sys.path.append('/home/patrick/geodj/templates')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
>
> What gives?

Since you have 'geodj' and going to guess you are using GeoDjango.

GeoDjango is either not thread safe, or uses a C extension module
which isn't safe to use in sub interpreters, I don't remember which.

Use:

  WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
  WSGIApplicationGroup %{GLOBAL}

That is, use single thread daemon processes and force it to run in
main interpreter.

So, change the WSGIDaemonProcess directive and add
WSGIApplicationGroup. Leave other directives as is.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

pcrutch

The problem still exists. I added the changes you suggested.

here is my sites-available file
----

   <VirtualHost *:8080>
        ServerName dragonfly.cens.ucla.edu

  WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
   WSGIApplicationGroup %{GLOBAL}
   WSGIProcessGroup dragonfly.cens.ucla.edu


        WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
        <Directory /home/patrick/geodj/>
            Order deny,allow
            Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
    </VirtualHost>

-----
sites-enabled file

<VirtualHost *:8080>
    #Basic setup
    ServerAdmin [hidden email]
    ServerName dragonfly.cens.ucla.edu
    ServerAlias dragonfly.cens.ucla.edu

    <Directory /home/patrick/geodj/>
        Order deny,allow
        Allow from all
    </Directory>

    LogLevel warn
    ErrorLog  /home/patrick/geodj/apache_error.log
    CustomLog /home/patrick/geodj/apache_access.log combined

   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
   WSGIApplicationGroup %{GLOBAL}
   WSGIProcessGroup dragonfly.cens.ucla.edu

    WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
</VirtualHost>

-----
my project .wsgi file

import os, sys
sys.path.append('/home/patrick/geodj')
sys.path.append('/home/patrick/geodj/templates')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

On Aug 6, 4:54 pm, Graham Dumpleton <[hidden email]>
wrote:

> On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:
>
>
>
> > So I run the dev server for my project and everything comes up fine,
> > map shows properly and loads the data correctly. However, using wsgi
> > the map loads and gives " Unhandled request return Internal Server
> > Error" and I checked the log file and I have the " premature end of
> > script headers" error. I have no clue why it won't load the data on
> > the map properly.
>
> > here is my sites-available file
> > ----
>
> >    <VirtualHost *:8080>
> >         ServerName dragonfly.cens.ucla.edu
>
> >         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> >         WSGIProcessGroup dragonfly.cens.ucla.edu
>
> >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> >         <Directory /home/patrick/geodj/>
> >             Order deny,allow
> >             Allow from all
> >         </Directory>
>
> >         ErrorLog /var/log/apache2/error.log
> >         LogLevel warn
>
> >         CustomLog /var/log/apache2/access.log combined
> >     </VirtualHost>
>
> > -----
> > sites-enabled file
>
> > <VirtualHost *:8080>
> >     #Basic setup
> >     ServerAdmin [hidden email]
> >     ServerName dragonfly.cens.ucla.edu
> >     ServerAlias dragonfly.cens.ucla.edu
>
> >     <Directory /home/patrick/geodj/>
> >         Order deny,allow
> >         Allow from all
> >     </Directory>
>
> >     LogLevel warn
> >     ErrorLog  /home/patrick/geodj/apache_error.log
> >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> >     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> >     WSGIProcessGroup dragonfly.cens.ucla.edu
>
> >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > </VirtualHost>
>
> > -----
> > my project .wsgi file
>
> > import os, sys
> > sys.path.append('/home/patrick/geodj')
> > sys.path.append('/home/patrick/geodj/templates')
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > import django.core.handlers.wsgi
>
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > What gives?
>
> Since you have 'geodj' and going to guess you are using GeoDjango.
>
> GeoDjango is either not thread safe, or uses a C extension module
> which isn't safe to use in sub interpreters, I don't remember which.
>
> Use:
>
>   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
>   WSGIApplicationGroup %{GLOBAL}
>
> That is, use single thread daemon processes and force it to run in
> main interpreter.
>
> So, change the WSGIDaemonProcess directive and add
> WSGIApplicationGroup. Leave other directives as is.
>
> Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

Graham Dumpleton-2



On Aug 8, 5:22 pm, pcrutch <[hidden email]> wrote:

> The problem still exists. I added the changes you suggested.
>
> here is my sites-available file
> ----
>
>    <VirtualHost *:8080>
>         ServerName dragonfly.cens.ucla.edu
>
>   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
>    WSGIApplicationGroup %{GLOBAL}
>    WSGIProcessGroup dragonfly.cens.ucla.edu
>
>         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
>         <Directory /home/patrick/geodj/>
>             Order deny,allow
>             Allow from all
>         </Directory>
>
>         ErrorLog /var/log/apache2/error.log
>         LogLevel warn
>
>         CustomLog /var/log/apache2/access.log combined
>     </VirtualHost>
>
> -----
> sites-enabled file
>
> <VirtualHost *:8080>
>     #Basic setup
>     ServerAdmin [hidden email]
>     ServerName dragonfly.cens.ucla.edu
>     ServerAlias dragonfly.cens.ucla.edu
>
>     <Directory /home/patrick/geodj/>
>         Order deny,allow
>         Allow from all
>     </Directory>

Safer to use:

     <Directory /home/patrick/geodj/apache>
         Order deny,allow
         Allow from all
     </Directory>

>     LogLevel warn
>     ErrorLog  /home/patrick/geodj/apache_error.log
>     CustomLog /home/patrick/geodj/apache_access.log combined
>
>    WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
>    WSGIApplicationGroup %{GLOBAL}
>    WSGIProcessGroup dragonfly.cens.ucla.edu
>
>     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> </VirtualHost>

Why are sites-available and sites-enabled different. If I understand
what you are talking about, one should be a file and the other a
symlink to the first file. Thus they should be exactly the same. Thus
how you are configuring your Apache isn't normal. You should fix that
up.

The configuration themselves look fine. If you had truly done a full
stop of Apache and then started it again, should pick up
configuration. If still have crashes, then try and hello world program
in place of you Django installation and make sure that your mod_wsgi
installation is running properly. See:

  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

If even that crashes, then likely you are using mod_python at same
time and it is causing crashes. See:

  http://code.google.com/p/modwsgi/wiki/InstallationIssues

If hello world works, but not Django, then and application is being
forced to main interpreter and single threaded, likely you have a
shared version library mismatch. This can occur with expat, MySQL and
other libraries. Have a good read through:

  http://code.google.com/p/modwsgi/wiki/ApplicationIssues

Also read through:

  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

Worst case you will need to use debugger as detailed in last part of
that to debug problem.

BTW, you really also need to provide more context from log file rather
than just that single line. Show what happened before and after that
point in log file. Also check main Apache error log to see if you are
getting segmentation fault messages.

Graham

> -----
> my project .wsgi file
>
> import os, sys
> sys.path.append('/home/patrick/geodj')
> sys.path.append('/home/patrick/geodj/templates')
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> import django.core.handlers.wsgi
>
> application = django.core.handlers.wsgi.WSGIHandler()
>
> On Aug 6, 4:54 pm, Graham Dumpleton <[hidden email]>
> wrote:
>
>
>
> > On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:
>
> > > So I run the dev server for my project and everything comes up fine,
> > > map shows properly and loads the data correctly. However, using wsgi
> > > the map loads and gives " Unhandled request return Internal Server
> > > Error" and I checked the log file and I have the " premature end of
> > > script headers" error. I have no clue why it won't load the data on
> > > the map properly.
>
> > > here is my sites-available file
> > > ----
>
> > >    <VirtualHost *:8080>
> > >         ServerName dragonfly.cens.ucla.edu
>
> > >         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > >         WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > >         <Directory /home/patrick/geodj/>
> > >             Order deny,allow
> > >             Allow from all
> > >         </Directory>
>
> > >         ErrorLog /var/log/apache2/error.log
> > >         LogLevel warn
>
> > >         CustomLog /var/log/apache2/access.log combined
> > >     </VirtualHost>
>
> > > -----
> > > sites-enabled file
>
> > > <VirtualHost *:8080>
> > >     #Basic setup
> > >     ServerAdmin [hidden email]
> > >     ServerName dragonfly.cens.ucla.edu
> > >     ServerAlias dragonfly.cens.ucla.edu
>
> > >     <Directory /home/patrick/geodj/>
> > >         Order deny,allow
> > >         Allow from all
> > >     </Directory>
>
> > >     LogLevel warn
> > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > >     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > >     WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > </VirtualHost>
>
> > > -----
> > > my project .wsgi file
>
> > > import os, sys
> > > sys.path.append('/home/patrick/geodj')
> > > sys.path.append('/home/patrick/geodj/templates')
>
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > import django.core.handlers.wsgi
>
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > What gives?
>
> > Since you have 'geodj' and going to guess you are using GeoDjango.
>
> > GeoDjango is either not thread safe, or uses a C extension module
> > which isn't safe to use in sub interpreters, I don't remember which.
>
> > Use:
>
> >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> >   WSGIApplicationGroup %{GLOBAL}
>
> > That is, use single thread daemon processes and force it to run in
> > main interpreter.
>
> > So, change the WSGIDaemonProcess directive and add
> > WSGIApplicationGroup. Leave other directives as is.
>
> > Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

Lee Trout

Interesting timing-- I have the same problem.  My basic testing django
app loads and works fine, but trying to access the admin causes the
seg fault.  Unfortunately I'll have to wait until my sys admin is
available on Monday to try Graham's vhost config suggestions...  I'm
hoping that fixes it.

On Aug 8, 6:45 am, Graham Dumpleton <[hidden email]>
wrote:

> On Aug 8, 5:22 pm, pcrutch <[hidden email]> wrote:
>
>
>
> > The problem still exists. I added the changes you suggested.
>
> > here is my sites-available file
> > ----
>
> >    <VirtualHost *:8080>
> >         ServerName dragonfly.cens.ucla.edu
>
> >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> >    WSGIApplicationGroup %{GLOBAL}
> >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> >         <Directory /home/patrick/geodj/>
> >             Order deny,allow
> >             Allow from all
> >         </Directory>
>
> >         ErrorLog /var/log/apache2/error.log
> >         LogLevel warn
>
> >         CustomLog /var/log/apache2/access.log combined
> >     </VirtualHost>
>
> > -----
> > sites-enabled file
>
> > <VirtualHost *:8080>
> >     #Basic setup
> >     ServerAdmin [hidden email]
> >     ServerName dragonfly.cens.ucla.edu
> >     ServerAlias dragonfly.cens.ucla.edu
>
> >     <Directory /home/patrick/geodj/>
> >         Order deny,allow
> >         Allow from all
> >     </Directory>
>
> Safer to use:
>
>      <Directory /home/patrick/geodj/apache>
>          Order deny,allow
>          Allow from all
>      </Directory>
>
> >     LogLevel warn
> >     ErrorLog  /home/patrick/geodj/apache_error.log
> >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> >    WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> >    WSGIApplicationGroup %{GLOBAL}
> >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > </VirtualHost>
>
> Why are sites-available and sites-enabled different. If I understand
> what you are talking about, one should be a file and the other a
> symlink to the first file. Thus they should be exactly the same. Thus
> how you are configuring your Apache isn't normal. You should fix that
> up.
>
> The configuration themselves look fine. If you had truly done a full
> stop of Apache and then started it again, should pick up
> configuration. If still have crashes, then try and hello world program
> in place of you Django installation and make sure that your mod_wsgi
> installation is running properly. See:
>
>  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> If even that crashes, then likely you are using mod_python at same
> time and it is causing crashes. See:
>
>  http://code.google.com/p/modwsgi/wiki/InstallationIssues
>
> If hello world works, but not Django, then and application is being
> forced to main interpreter and single threaded, likely you have a
> shared version library mismatch. This can occur with expat, MySQL and
> other libraries. Have a good read through:
>
>  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
>
> Also read through:
>
>  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
>
> Worst case you will need to use debugger as detailed in last part of
> that to debug problem.
>
> BTW, you really also need to provide more context from log file rather
> than just that single line. Show what happened before and after that
> point in log file. Also check main Apache error log to see if you are
> getting segmentation fault messages.
>
> Graham
>
> > -----
> > my project .wsgi file
>
> > import os, sys
> > sys.path.append('/home/patrick/geodj')
> > sys.path.append('/home/patrick/geodj/templates')
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > import django.core.handlers.wsgi
>
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > On Aug 6, 4:54 pm, Graham Dumpleton <[hidden email]>
> > wrote:
>
> > > On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:
>
> > > > So I run the dev server for my project and everything comes up fine,
> > > > map shows properly and loads the data correctly. However, using wsgi
> > > > the map loads and gives " Unhandled request return Internal Server
> > > > Error" and I checked the log file and I have the " premature end of
> > > > script headers" error. I have no clue why it won't load the data on
> > > > the map properly.
>
> > > > here is my sites-available file
> > > > ----
>
> > > >    <VirtualHost *:8080>
> > > >         ServerName dragonfly.cens.ucla.edu
>
> > > >         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > >         WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > >         <Directory /home/patrick/geodj/>
> > > >             Order deny,allow
> > > >             Allow from all
> > > >         </Directory>
>
> > > >         ErrorLog /var/log/apache2/error.log
> > > >         LogLevel warn
>
> > > >         CustomLog /var/log/apache2/access.log combined
> > > >     </VirtualHost>
>
> > > > -----
> > > > sites-enabled file
>
> > > > <VirtualHost *:8080>
> > > >     #Basic setup
> > > >     ServerAdmin [hidden email]
> > > >     ServerName dragonfly.cens.ucla.edu
> > > >     ServerAlias dragonfly.cens.ucla.edu
>
> > > >     <Directory /home/patrick/geodj/>
> > > >         Order deny,allow
> > > >         Allow from all
> > > >     </Directory>
>
> > > >     LogLevel warn
> > > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > > >     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > >     WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > </VirtualHost>
>
> > > > -----
> > > > my project .wsgi file
>
> > > > import os, sys
> > > > sys.path.append('/home/patrick/geodj')
> > > > sys.path.append('/home/patrick/geodj/templates')
>
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > > import django.core.handlers.wsgi
>
> > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > What gives?
>
> > > Since you have 'geodj' and going to guess you are using GeoDjango.
>
> > > GeoDjango is either not thread safe, or uses a C extension module
> > > which isn't safe to use in sub interpreters, I don't remember which.
>
> > > Use:
>
> > >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > >   WSGIApplicationGroup %{GLOBAL}
>
> > > That is, use single thread daemon processes and force it to run in
> > > main interpreter.
>
> > > So, change the WSGIDaemonProcess directive and add
> > > WSGIApplicationGroup. Leave other directives as is.
>
> > > Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

Lee Trout

On Aug 8, 5:55 pm, Lee <[hidden email]> wrote:

> Interesting timing-- I have the same problem.  My basic testing django
> app loads and works fine, but trying to access the admin causes the
> seg fault.  Unfortunately I'll have to wait until my sys admin is
> available on Monday to try Graham's vhost config suggestions...  I'm
> hoping that fixes it.
>
> On Aug 8, 6:45 am, Graham Dumpleton <[hidden email]>
> wrote:
>
> > On Aug 8, 5:22 pm, pcrutch <[hidden email]> wrote:
>
> > > The problem still exists. I added the changes you suggested.
>
> > > here is my sites-available file
> > > ----
>
> > >    <VirtualHost *:8080>
> > >         ServerName dragonfly.cens.ucla.edu
>
> > >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > >    WSGIApplicationGroup %{GLOBAL}
> > >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > >         <Directory /home/patrick/geodj/>
> > >             Order deny,allow
> > >             Allow from all
> > >         </Directory>
>
> > >         ErrorLog /var/log/apache2/error.log
> > >         LogLevel warn
>
> > >         CustomLog /var/log/apache2/access.log combined
> > >     </VirtualHost>
>
> > > -----
> > > sites-enabled file
>
> > > <VirtualHost *:8080>
> > >     #Basic setup
> > >     ServerAdmin [hidden email]
> > >     ServerName dragonfly.cens.ucla.edu
> > >     ServerAlias dragonfly.cens.ucla.edu
>
> > >     <Directory /home/patrick/geodj/>
> > >         Order deny,allow
> > >         Allow from all
> > >     </Directory>
>
> > Safer to use:
>
> >      <Directory /home/patrick/geodj/apache>
> >          Order deny,allow
> >          Allow from all
> >      </Directory>
>
> > >     LogLevel warn
> > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > >    WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > >    WSGIApplicationGroup %{GLOBAL}
> > >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > </VirtualHost>
>
> > Why are sites-available and sites-enabled different. If I understand
> > what you are talking about, one should be a file and the other a
> > symlink to the first file. Thus they should be exactly the same. Thus
> > how you are configuring your Apache isn't normal. You should fix that
> > up.
>
> > The configuration themselves look fine. If you had truly done a full
> > stop of Apache and then started it again, should pick up
> > configuration. If still have crashes, then try and hello world program
> > in place of you Django installation and make sure that your mod_wsgi
> > installation is running properly. See:
>
> >  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> > If even that crashes, then likely you are using mod_python at same
> > time and it is causing crashes. See:
>
> >  http://code.google.com/p/modwsgi/wiki/InstallationIssues
>
> > If hello world works, but not Django, then and application is being
> > forced to main interpreter and single threaded, likely you have a
> > shared version library mismatch. This can occur with expat, MySQL and
> > other libraries. Have a good read through:
>
> >  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
>
> > Also read through:
>
> >  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
>
> > Worst case you will need to use debugger as detailed in last part of
> > that to debug problem.
>
> > BTW, you really also need to provide more context from log file rather
> > than just that single line. Show what happened before and after that
> > point in log file. Also check main Apache error log to see if you are
> > getting segmentation fault messages.
>
> > Graham
>
> > > -----
> > > my project .wsgi file
>
> > > import os, sys
> > > sys.path.append('/home/patrick/geodj')
> > > sys.path.append('/home/patrick/geodj/templates')
>
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > import django.core.handlers.wsgi
>
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > On Aug 6, 4:54 pm, Graham Dumpleton <[hidden email]>
> > > wrote:
>
> > > > On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:
>
> > > > > So I run the dev server for my project and everything comes up fine,
> > > > > map shows properly and loads the data correctly. However, using wsgi
> > > > > the map loads and gives " Unhandled request return Internal Server
> > > > > Error" and I checked the log file and I have the " premature end of
> > > > > script headers" error. I have no clue why it won't load the data on
> > > > > the map properly.
>
> > > > > here is my sites-available file
> > > > > ----
>
> > > > >    <VirtualHost *:8080>
> > > > >         ServerName dragonfly.cens.ucla.edu
>
> > > > >         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > > >         WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > >         <Directory /home/patrick/geodj/>
> > > > >             Order deny,allow
> > > > >             Allow from all
> > > > >         </Directory>
>
> > > > >         ErrorLog /var/log/apache2/error.log
> > > > >         LogLevel warn
>
> > > > >         CustomLog /var/log/apache2/access.log combined
> > > > >     </VirtualHost>
>
> > > > > -----
> > > > > sites-enabled file
>
> > > > > <VirtualHost *:8080>
> > > > >     #Basic setup
> > > > >     ServerAdmin [hidden email]
> > > > >     ServerName dragonfly.cens.ucla.edu
> > > > >     ServerAlias dragonfly.cens.ucla.edu
>
> > > > >     <Directory /home/patrick/geodj/>
> > > > >         Order deny,allow
> > > > >         Allow from all
> > > > >     </Directory>
>
> > > > >     LogLevel warn
> > > > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > > > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > > > >     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > > >     WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > > </VirtualHost>
>
> > > > > -----
> > > > > my project .wsgi file
>
> > > > > import os, sys
> > > > > sys.path.append('/home/patrick/geodj')
> > > > > sys.path.append('/home/patrick/geodj/templates')
>
> > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > > > import django.core.handlers.wsgi
>
> > > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > > What gives?
>
> > > > Since you have 'geodj' and going to guess you are using GeoDjango.
>
> > > > GeoDjango is either not thread safe, or uses a C extension module
> > > > which isn't safe to use in sub interpreters, I don't remember which.
>
> > > > Use:
>
> > > >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > > >   WSGIApplicationGroup %{GLOBAL}
>
> > > > That is, use single thread daemon processes and force it to run in
> > > > main interpreter.
>
> > > > So, change the WSGIDaemonProcess directive and add
> > > > WSGIApplicationGroup. Leave other directives as is.
>
> > > > Graham


My issue was using sqlite and the directory the db file was in didn't
have write permission even though the actual database file did...
Switching my log level to debug was a big help in uncovering the
segmentation fault issue at hand.

I might not be of much use here, but maybe it will help someone else
who googles the same error and lands here like I did.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mod_wsgi and Apache Problems - Unhandled request return Internal Server Error / Premature end of script headers

Graham Dumpleton-2



On Aug 9, 3:12 pm, Lee <[hidden email]> wrote:

> On Aug 8, 5:55 pm, Lee <[hidden email]> wrote:
>
>
>
>
>
> > Interesting timing-- I have the same problem.  My basic testing django
> > app loads and works fine, but trying to access the admin causes the
> > seg fault.  Unfortunately I'll have to wait until my sys admin is
> > available on Monday to try Graham's vhost config suggestions...  I'm
> > hoping that fixes it.
>
> > On Aug 8, 6:45 am, Graham Dumpleton <[hidden email]>
> > wrote:
>
> > > On Aug 8, 5:22 pm, pcrutch <[hidden email]> wrote:
>
> > > > The problem still exists. I added the changes you suggested.
>
> > > > here is my sites-available file
> > > > ----
>
> > > >    <VirtualHost *:8080>
> > > >         ServerName dragonfly.cens.ucla.edu
>
> > > >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > > >    WSGIApplicationGroup %{GLOBAL}
> > > >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > >         <Directory /home/patrick/geodj/>
> > > >             Order deny,allow
> > > >             Allow from all
> > > >         </Directory>
>
> > > >         ErrorLog /var/log/apache2/error.log
> > > >         LogLevel warn
>
> > > >         CustomLog /var/log/apache2/access.log combined
> > > >     </VirtualHost>
>
> > > > -----
> > > > sites-enabled file
>
> > > > <VirtualHost *:8080>
> > > >     #Basic setup
> > > >     ServerAdmin [hidden email]
> > > >     ServerName dragonfly.cens.ucla.edu
> > > >     ServerAlias dragonfly.cens.ucla.edu
>
> > > >     <Directory /home/patrick/geodj/>
> > > >         Order deny,allow
> > > >         Allow from all
> > > >     </Directory>
>
> > > Safer to use:
>
> > >      <Directory /home/patrick/geodj/apache>
> > >          Order deny,allow
> > >          Allow from all
> > >      </Directory>
>
> > > >     LogLevel warn
> > > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > > >    WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > > >    WSGIApplicationGroup %{GLOBAL}
> > > >    WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > </VirtualHost>
>
> > > Why are sites-available and sites-enabled different. If I understand
> > > what you are talking about, one should be a file and the other a
> > > symlink to the first file. Thus they should be exactly the same. Thus
> > > how you are configuring your Apache isn't normal. You should fix that
> > > up.
>
> > > The configuration themselves look fine. If you had truly done a full
> > > stop of Apache and then started it again, should pick up
> > > configuration. If still have crashes, then try and hello world program
> > > in place of you Django installation and make sure that your mod_wsgi
> > > installation is running properly. See:
>
> > >  http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
>
> > > If even that crashes, then likely you are using mod_python at same
> > > time and it is causing crashes. See:
>
> > >  http://code.google.com/p/modwsgi/wiki/InstallationIssues
>
> > > If hello world works, but not Django, then and application is being
> > > forced to main interpreter and single threaded, likely you have a
> > > shared version library mismatch. This can occur with expat, MySQL and
> > > other libraries. Have a good read through:
>
> > >  http://code.google.com/p/modwsgi/wiki/ApplicationIssues
>
> > > Also read through:
>
> > >  http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
>
> > > Worst case you will need to use debugger as detailed in last part of
> > > that to debug problem.
>
> > > BTW, you really also need to provide more context from log file rather
> > > than just that single line. Show what happened before and after that
> > > point in log file. Also check main Apache error log to see if you are
> > > getting segmentation fault messages.
>
> > > Graham
>
> > > > -----
> > > > my project .wsgi file
>
> > > > import os, sys
> > > > sys.path.append('/home/patrick/geodj')
> > > > sys.path.append('/home/patrick/geodj/templates')
>
> > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > > import django.core.handlers.wsgi
>
> > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > On Aug 6, 4:54 pm, Graham Dumpleton <[hidden email]>
> > > > wrote:
>
> > > > > On Aug 7, 7:43 am, pcrutch <[hidden email]> wrote:
>
> > > > > > So I run the dev server for my project and everything comes up fine,
> > > > > > map shows properly and loads the data correctly. However, using wsgi
> > > > > > the map loads and gives " Unhandled request return Internal Server
> > > > > > Error" and I checked the log file and I have the " premature end of
> > > > > > script headers" error. I have no clue why it won't load the data on
> > > > > > the map properly.
>
> > > > > > here is my sites-available file
> > > > > > ----
>
> > > > > >    <VirtualHost *:8080>
> > > > > >         ServerName dragonfly.cens.ucla.edu
>
> > > > > >         WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > > > >         WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > > > >         WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > > >         <Directory /home/patrick/geodj/>
> > > > > >             Order deny,allow
> > > > > >             Allow from all
> > > > > >         </Directory>
>
> > > > > >         ErrorLog /var/log/apache2/error.log
> > > > > >         LogLevel warn
>
> > > > > >         CustomLog /var/log/apache2/access.log combined
> > > > > >     </VirtualHost>
>
> > > > > > -----
> > > > > > sites-enabled file
>
> > > > > > <VirtualHost *:8080>
> > > > > >     #Basic setup
> > > > > >     ServerAdmin [hidden email]
> > > > > >     ServerName dragonfly.cens.ucla.edu
> > > > > >     ServerAlias dragonfly.cens.ucla.edu
>
> > > > > >     <Directory /home/patrick/geodj/>
> > > > > >         Order deny,allow
> > > > > >         Allow from all
> > > > > >     </Directory>
>
> > > > > >     LogLevel warn
> > > > > >     ErrorLog  /home/patrick/geodj/apache_error.log
> > > > > >     CustomLog /home/patrick/geodj/apache_access.log combined
>
> > > > > >     WSGIDaemonProcess dragonfly.cens.ucla.edu threads=25
> > > > > >     WSGIProcessGroup dragonfly.cens.ucla.edu
>
> > > > > >     WSGIScriptAlias / /home/patrick/geodj/apache/sitez.wsgi
> > > > > > </VirtualHost>
>
> > > > > > -----
> > > > > > my project .wsgi file
>
> > > > > > import os, sys
> > > > > > sys.path.append('/home/patrick/geodj')
> > > > > > sys.path.append('/home/patrick/geodj/templates')
>
> > > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
>
> > > > > > import django.core.handlers.wsgi
>
> > > > > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > > > > What gives?
>
> > > > > Since you have 'geodj' and going to guess you are using GeoDjango.
>
> > > > > GeoDjango is either not thread safe, or uses a C extension module
> > > > > which isn't safe to use in sub interpreters, I don't remember which.
>
> > > > > Use:
>
> > > > >   WSGIDaemonProcess dragonfly.cens.ucla.edu processes=4 threads=1
> > > > >   WSGIApplicationGroup %{GLOBAL}
>
> > > > > That is, use single thread daemon processes and force it to run in
> > > > > main interpreter.
>
> > > > > So, change the WSGIDaemonProcess directive and add
> > > > > WSGIApplicationGroup. Leave other directives as is.
>
> > > > > Graham
>
> My issue was using sqlite and the directory the db file was in didn't
> have write permission even though the actual database file did...
> Switching my log level to debug was a big help in uncovering the
> segmentation fault issue at hand.
>
> I might not be of much use here, but maybe it will help someone else
> who googles the same error and lands here like I did.

That may have result in a 500 error, but not the 'Premature end of
script headers' error. The latter indicates that the mod_wsgi daemon
process crashed altogether. In your case it would be highly unlikely
that the process itself crashed and exited.

Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---