1

Django プロジェクトを、DreamHost がホストする運用 CentOS サーバーに移動することに行き詰まりました。Apache 2.2.23 と Python 2.6.6 がインストールされました。Django 1.4 と mod_wsgi 3.4 をインストールして構成しました。入力してApacheを再起動すると(Webアプリが完全に実行されることを期待しています)

sudo apachectl restart

/usr/local/apache/logs/ 内の Apache の error_log を調べると、次のように表示されます。

[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 ''.

Pythonパスと関係があるように感じます。推測ですが。Python がクラッシュし続けているようです。

/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

httpd.conf の関連部分は次のとおりです。

<VirtualHost *:80>

    ServerName myproject.mysite.net
    ServerAdmin myemail@abc.com

    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>

ここに私の 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()

ここに私の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]

また、「mysite.net」ではなく「myproject.mysite.net」という URL としてホストしようとしています。私がそれを正しく行っているかどうかもわかりません。

4

1 に答える 1

1

実際の問題は何ですか?リクエストを行うときに実際にエラーが発生していますか。

ログ出力は完全に正常に見えます。すべての個別のプロセスは、Python が Apache の子ワーカー プロセスでも初期化されているためです。設定:

WSGIRestrictEmbedded On

彼らは立ち去り、1 つのプロセスだけを見る必要があります。

そのディレクティブに関する注意事項については、以下を参照してください。

http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html

ところで、「プロセス = 1 スレッド = 1」を使用するのは悪い選択のようです。一度に 1 つの要求しか処理できません。

于 2012-11-13T10:30:56.890 に答える