看板 Python 關於我們 聯絡資訊
我的環境是ubuntu16.04 系統python --version ->python2.7 系統python3 --version ->python3.6 apache 2.4 libapache2-mod-wsgi-py3 我用pycharm使用 virtualenv 版本python3.6 創了一個django專案 apache測試 wsgi 模組 是成功的 以下是我的相關配置 (我的/etc/hosts 有設置127.0.0.1 test.test.com) 目錄權限/var/www/html/mirror 擁有者www-data 權限777 先全開之後成功再改 apache virtualhost配置 ------------------------------------------------ <VirtualHost *:80> ServerName test.test.com DocumentRoot /var/www/html/mirror WSGIScriptAlias / /var/www/html/mirror/mirror/wsgi.py ErrorLog /tmp/wsgitest.log CustomLog /tmp/wsgiaccess.log combined </VirtualHost> ------------------------------------------------- /var/www/html/mirrir/mirror/wsgi.py配置如下 ------------------------------------------------- import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mirror.settings") application = get_wsgi_application() -------------------------------------------------- 以下是我的apache log mod_wsgi (pid=5854): Target WSGI script '/var/www/html/mirror/mirror/wsgi.py' cannot be loaded as Python module. mod_wsgi (pid=5854): Exception occurred processing WSGI script '/var/www/html/mirror/mirror/wsgi.py' Traceback (most recent call last): File "/var/www/html/mirror/mirror/wsgi.py", line 11, in <module> from django.core.wsgi import get_wsgi_application ImportError: No module named 'django' mod_wsgi (pid=5856): Target WSGI script '/var/www/html/mirror/mirror/wsgi.py' cannot be loaded as Python module., referer: http://test.test.com/ 因為我ubuntu原本就是使用apache 也有其他專案 所以沒有改用nginx 這是我練習python的第一個專案 使用runserver 都可以正常run 想部署到apache 卻無論如何都失敗 想請高手指導一下 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.34.127.221 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1527047329.A.D42.html
s06yji3: 環境中的python沒有安裝Django? 05/23 12:18
billy0131: wsgi.py裡面要active virtualenv 05/23 12:59
billy0131: 可參考: https://goo.gl/zBSmv1 05/23 13:00