2015-03-13 31 views
1

我甚至不知道我是多麼想部署具有apachemod_wsgi一個Django應用程序,但仍然一次又一次地得到了同樣的錯誤,這是wsgi.py文件:權限被拒絕激活virtualenv中使用Apache + mod_wsgi的+ Django的CentOS中7

""" 
WSGI config for progress_bar project. 

It exposes the WSGI callable as a module-level variable named ``application``. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ 
""" 

import os 
import sys 
import site 

# Add the site-packages of the chosen virtualenv to work with 
site.addsitedir('/home/tone/entornos/progressbar/lib/python2.7/site-packages') 


sys.path.append('/var/www/html/progress_bar/progress_bar') 
sys.path.append('/var/www/html/progress_bar') 


# Add virtualenv and activate for apache 
    activate_env=os.path.expanduser("/home/tone/entornos/progressbar/bin/activate_this.py") 
execfile(activate_env, dict(__file__=activate_env)) 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "progress_bar.settings") 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

而且virtual-host配置:

<VirtualHost *:80> 
    #WSGIDaemonProcess python-path=/home/tone/entornos/progressbar/lib/python2.7/site-packages 
    #WSGIPythonPath /home/tone/entornos/progressbar/bin:/home/tone/entornos/progressbar/lib/python2.7/site-packages 

    WSGIScriptAlias /progress-django-upload /var/www/html/progress_bar/progress_bar/wsgi.py 

    <Directory /var/www/html/progress_bar> 
     Require all granted 
    </Directory> 
</VirtualHost> 

但我總是試圖進入電影我有一個很好的誤差500和日誌說的一樣:

[Fri Mar 13 13:19:12.427639 2015] [:error] [pid 4217] [client 150.214.108.153:50376] mod_wsgi (pid=4217): Target WSGI script '/var/www/html/progress_ba$ 
    [Fri Mar 13 13:19:12.427799 2015] [:error] [pid 4217] [client 150.214.108.153:50376] mod_wsgi (pid=4217): Exception occurred processing WSGI script '/v$ 
    [Fri Mar 13 13:19:12.427894 2015] [:error] [pid 4217] [client 150.214.108.153:50376] Traceback (most recent call last): 
    [Fri Mar 13 13:19:12.427981 2015] [:error] [pid 4217] [client 150.214.108.153:50376] File "/var/www/html/progress_bar/progress_bar/wsgi.py", line 24,$ 
    [Fri Mar 13 13:19:12.428421 2015] [:error] [pid 4217] [client 150.214.108.153:50376]  execfile(activate_env, dict(__file__=activate_env)) 
    [Fri Mar 13 13:19:12.428567 2015] [:error] [pid 4217] [client 150.214.108.153:50376] IOError: [Errno 13] Permission denied: '/home/tone/entornos/progre$ 
    [Fri Mar 13 13:19:14.450602 2015] [:error] [pid 4216] [client 150.214.108.153:50377] mod_wsgi (pid=4216): Target WSGI script '/var/www/html/progress_ba$ 
    [Fri Mar 13 13:19:14.450722 2015] [:error] [pid 4216] [client 150.214.108.153:50377] mod_wsgi (pid=4216): Exception occurred processing WSGI script '/v$ 
    [Fri Mar 13 13:19:14.450811 2015] [:error] [pid 4216] [client 150.214.108.153:50377] Traceback (most recent call last): 
    [Fri Mar 13 13:19:14.450889 2015] [:error] [pid 4216] [client 150.214.108.153:50377] File "/var/www/html/progress_bar/progress_bar/wsgi.py", line 24,$ 
    [Fri Mar 13 13:19:14.451162 2015] [:error] [pid 4216] [client 150.214.108.153:50377]  execfile(activate_env, dict(__file__=activate_env)) 
    [Fri Mar 13 13:19:14.451249 2015] [:error] [pid 4216] [client 150.214.108.153:50377] IOError: [Errno 13] Permission denied: '/home/tone/entornos/progre$ 

在你回答之前......是的,我有chown -R apache:apache /home/tone/entornos/progressbar/bin設置權限爲Apache甚至activate_this.pychomd 777 ...甚至temporaly禁用SELinux對於此而已......總是與權限一樣...有些人有這個問題的魔杖?

問候!

回答

0

最後sudo chmod -R 755 /home/tone做了工作!我不知道這是否是一個好習慣,只需授予所有組讀取和執行整個主目錄的權限,但是現在這是一個很好的解決方法。