Reputation: 557
I've been stuck on moving my Django project to a production CentOS server hosted by DreamHost. Apache 2.2.23 and Python 2.6.6 came installed. I have installed and configured Django 1.4 and mod_wsgi 3.4. When I restart Apache (hoping that the web app will run perfectly) by typing
sudo apachectl restart
I look in Apache's error_log within /usr/local/apache/logs/ and see this:
[Mon Nov 12 18:05:24 2012] [info] Init: Seeding PRNG with 144 bytes of entropy
[Mon Nov 12 18:05:24 2012] [notice] SSL FIPS mode disabled
[Mon Nov 12 18:05:24 2012] [info] Loading certificate & private key of SSL-aware server
[Mon Nov 12 18:05:24 2012] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Mon Nov 12 18:05:24 2012] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Mon Nov 12 18:05:24 2012] [info] Init: Initializing (virtual) servers for SSL
[Mon Nov 12 18:05:24 2012] [info] Configuring server for SSL protocol
[Mon Nov 12 18:05:24 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Nov 12 18:05:24 2012] [info] mod_ssl/2.2.23 compiled against Server: Apache/2.2.23, Library: OpenSSL/1.0.0-fips
[Mon Nov 12 18:05:24 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Mon Nov 12 18:05:24 2012] [info] Init: Seeding PRNG with 144 bytes of entropy
[Mon Nov 12 18:05:24 2012] [notice] SSL FIPS mode disabled
[Mon Nov 12 18:05:24 2012] [info] Loading certificate & private key of SSL-aware server
[Mon Nov 12 18:05:24 2012] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Mon Nov 12 18:05:24 2012] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Mon Nov 12 18:05:24 2012] [info] Init: Initializing (virtual) servers for SSL
[Mon Nov 12 18:05:24 2012] [info] Configuring server for SSL protocol
[Mon Nov 12 18:05:24 2012] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Mon Nov 12 18:05:24 2012] [info] mod_ssl/2.2.23 compiled against Server: Apache/2.2.23, Library: OpenSSL/1.0.0-fips
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30259): Starting process 'myproject.mysite.net' with uid=99, gid=99 and threads=1.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30259): Initializing Python.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30260): Initializing Python.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30261): Initializing Python.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30262): Initializing Python.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30263): Initializing Python.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30264): Initializing Python.
[Mon Nov 12 18:05:24 2012] [notice] Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_wsgi/3.4 Python/2.6.6 configured -- resuming normal operations
[Mon Nov 12 18:05:24 2012] [info] Server built: Oct 21 2012 05:57:19
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30259): Attach interpreter ''.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30260): Attach interpreter ''.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30262): Attach interpreter ''.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30261): Attach interpreter ''.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30263): Attach interpreter ''.
[Mon Nov 12 18:05:24 2012] [info] mod_wsgi (pid=30264): Attach interpreter ''.
[Mon Nov 12 18:05:28 2012] [info] mod_wsgi (pid=30270): Initializing Python.
[Mon Nov 12 18:05:28 2012] [info] mod_wsgi (pid=30270): Attach interpreter ''.
[Mon Nov 12 18:07:50 2012] [info] mod_wsgi (pid=30311): Initializing Python.
[Mon Nov 12 18:07:50 2012] [info] mod_wsgi (pid=30311): Attach interpreter ''.
[Mon Nov 12 18:07:51 2012] [info] [client 24.143.104.168] (32)Broken pipe: core_output_filter: writing data to the network
[Mon Nov 12 18:10:44 2012] [info] [client 180.76.5.64] (104)Connection reset by peer: core_output_filter: writing data to the network
[Mon Nov 12 18:11:26 2012] [info] mod_wsgi (pid=30356): Initializing Python.
[Mon Nov 12 18:11:26 2012] [info] mod_wsgi (pid=30356): Attach interpreter ''.
I feel like it might have something to do with the Python path. Just a guess though. It definitely looks like Python keeps crashing.
/home
/myproject
/public_html (server document root)
/django_proj
/myproject (django project root)
settings.py
other files and app directories for this django project
/apache
wsgi.py
django.wsgi
Here is the relevant part of httpd.conf:
<VirtualHost *:80>
ServerName myproject.mysite.net
ServerAdmin [email protected]
DocumentRoot /home/myproject/django_proj/myproject
<Directory /home/myproject/django_proj/myproject>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess myproject.mysite.net processes=1 threads=1 display-name=%{GROUP}
WSGIProcessGroup myproject.mysite.net
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /home/myproject/django_proj/myproject/apache/django.wsgi
<Directory /home/myproject/django_proj/myproject/apache>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Here is my wsgi.py:
import os
path = '/home/myproject/django_proj'
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Here is my django.wsgi:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
I'm also trying to host it as the URL "myproject.mysite.net" instead of just "mysite.net". Not sure if I've been doing that right, either.
Upvotes: 1
Views: 1676
Reputation: 58523
What is the actual problem? Are you actually getting an error when you make requests.
The log output looks perfectly normal. All the separate processes are because Python is also being initialised in the Apache child worker processes. Set:
WSGIRestrictEmbedded On
and they will go away and should see just the one process.
For notes on that directive see:
http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html
BTW, using 'processes=1 threads=1' seems a bad choice. Can only handle one request at a time.
Upvotes: 1