-1

私はローカルで Django を使用してきましたが、現在、実行中の Ubuntu サーバー ( http://www.youtube.com/watch?v=hBMVVruB9Vs ) の本番 Apache 環境にコードをプッシュしようとしています。

ただし、ディレクトリ内のファイルのリストを取得するだけで、他には何も取得しません。まず、ターミナルでコマンド Python を実行して、Python がインストールされていることを確認しました。

次のコマンドを使用して、apaache と mod wsgi をインストールしました。

sudo apt-get install apache2 sudo apt-get install libapache2-mod-wsgi

そして、それが有効になっていることを確認するためにテストしました。

ルートにある私のwsgiファイルfirstweb.wsgiは次のとおりです。

import os
import sys
sys.path.append('/var/www/firstweb')
os.environ['DJANGO_SETTINGS_MODULE'] = 'firstweb.settings'

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

これが私の firstweb.conf ファイルです。

<VirtualHost *:80>

WSGIScriptAlias / /firstweb.wsgi

Alias /static /var/www/firstweb/static 

<Directory /var/www/firstweb/>
Order allow,deny
Allow from all 
</Directory>

</VirtualHost>

私の Django プロジェクトは /var/www/firstweb/ にあります。

正直なところ、ここで何が問題なのかわかりません。ビデオ内では問題なく動作しています! :(

編集、ここにエラーログがあります:

[Sat Feb 16 16:19:31 2013] [notice] Apache/2.2.22 (Ubuntu) configured -- resuming normal operations
[Sat Feb 16 16:20:46 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:20:47 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:20:47 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:20:47 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 16:37:05 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:37:06 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:37:06 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:37:06 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 16:37:17 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:20 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:24 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:24 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:24 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:25 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:25 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:37:26 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:38:01 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:39:19 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:39:20 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:39:20 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:39:20 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 16:39:24 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:39:42 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:48:00 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:48:02 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:49:51 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:49:52 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:49:52 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:49:52 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 16:49:55 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:49:56 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:49:58 2013] [error] [client 131.231.153.48] File does not exist: /var/www/favicon.ico
[Sat Feb 16 16:53:21 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:53:22 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:53:22 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:53:22 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 16:55:34 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 16:55:35 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 16:55:35 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 16:55:35 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
[Sat Feb 16 17:00:07 2013] [notice] caught SIGTERM, shutting down
[Sat Feb 16 17:00:08 2013] [warn] mod_wsgi: Compiled for Python/2.7.2+.
[Sat Feb 16 17:00:08 2013] [warn] mod_wsgi: Runtime using Python/2.7.3.
[Sat Feb 16 17:00:08 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations
4

3 に答える 3

0

次のように仮想ホストを構成してみてください。

 <Directory /var/www/firstweb/static>
   Order allow,deny
    Option Indexes
    Allow from all 
  </Directory>

   WSGIScriptAlias / /full-system-path-to/firstweb/wsgi.py

それが機能しない場合は、Directoryタグに変更を加えて、上記のように最後にstaticを追加するだけです。staticを追加しないことで、ディレクトリ内のファイルが表示されると思います。

于 2013-02-16T19:27:03.057 に答える
-1

次のように仮想ホストを構成します。

<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/production/myApp

<Directory />
    Order Deny,Allow
    Deny from all
    Options None
    AllowOverride None
</Directory>
<Directory /var/production/myApp>
    Options None
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

WSGIDaemonProcess mysite.com python-path=/var/production/myApp:/var/production/myApp/venv/lib/python2.7/site-packages
WSGIProcessGroup misite.com
WSGIScriptAlias / /var/production/myApp/myApp/wsgi.py

Alias /static   /var/production/myApp/static

<Directory /var/production/myApp/static>
    Options None
    AllowOverride None
    Order Allow,Deny
    Allow from all
</Directory>

「/var/production/myApp」をアプリのパスに置き換えます

さらにヘルプが必要な場合は、このチュートリアルをご覧ください

于 2013-11-28T10:24:21.693 に答える
-1

質問 1: wsgi mod を有効にしましたか?

sudo a2enmod mod-wsgi

質問 2: AddHandler ステートメントはどこにありますか?

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AddHandler cgi-script .cgi
    AddHandler wsgi-script .wsgi
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

.wsgiファイルを wsgi アプリケーションに関連付ける方法を apache が認識しているとは思えません。

于 2014-05-23T21:53:16.307 に答える