我有,httpd.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.hello2.ch
DocumentRoot /home/django_www/hello
WSGIScriptAlias / /var/www/django_www/hardi/django.wsgi
ErrorLog /var/www/django_www/hardi/error_log
CustomLog /var/www/django_www/hardi/access_log common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
127.0.0.1 localhost.localdomain localhost
128.178.131.89 www.hello2.ch
128.178.131.89 ohtersite.ch
python 2.5,mod_wsgi-2.5,/ root / epd-5.1.0/lib/libpython2.5.so.1.0:已安装!
libpython2.5.so.1.0 => /root/epd-5.1.0/lib/libpython2.5.so.1.0 (0x00002b1bb7333000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003da0600000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003d9fe00000)
libutil.so.1 => /lib64/libutil.so.1 (0x0000003dadc00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003da0200000)
libc.so.6 => /lib64/libc.so.6 (0x0000003d9fa00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003d9f600000)
/root/epd-5.1.0/lib /
但是当我尝试加载网页时,我收到以下error_log:
'import site' failed; use -v for traceback
[Wed Aug 29 11:52:57 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Aug 29 11:52:57 2012] [notice] Digest: generating secret for digest authentication ...
[Wed Aug 29 11:52:57 2012] [notice] Digest: done
[Wed Aug 29 11:52:57 2012] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Aug 29 11:52:57 2012] [notice] Apache/2.2.3 (Red Hat) configured -- resuming normal operations
[Wed Aug 29 11:55:00 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 11:58:30 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:01:58 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:05:30 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:09:00 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:12:29 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:14:06 2012] [error] [client 178.33.137.225] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
[Wed Aug 29 12:15:59 2012] [error] [client 66.249.72.187] Symbolic link not allowed or link target not accessible: /var/www/html/app/webroot/w3
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
....
'import site' failed; use -v for traceback
[Wed Aug 29 12:17:47 2012] [notice] caught SIGTERM, shutting down
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
[Wed Aug 29 12:17:47 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Aug 29 12:17:47 2012] [notice] Digest: generating secret for digest authentication ...
[Wed Aug 29 12:17:47 2012] [notice] Digest: done
[Wed Aug 29 12:17:47 2012] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Aug 29 12:17:47 2012] [notice] Apache/2.2.3 (Red Hat) configured -- resuming normal operations
[Wed Aug 29 12:18:01 2012] [error] Traceback (most recent call last):
[Wed Aug 29 12:18:01 2012] [error] File "/var/www/django_www/hardi/django.wsgi", line 1, in <module>
[Wed Aug 29 12:18:01 2012] [error] import os
[Wed Aug 29 12:18:01 2012] [error] ImportError: No module named os
任何想法,如何使Django与mod_wsgi一起工作,以及如何使第一个VirtualHost条目与www.hello2.ch网页以及第二个VirtualHost条目中的所有其他条目相匹配?
答案 0 :(得分:1)
在mod_wsgi.so上运行'ldd'。
问题可能在于找到不同的Python版本。也可能是因为你的Python不在标准位置,所以它不知道在哪里找到安装。
在后一种情况下,在Apache配置中添加VirtualHost之外的全局范围:
WSGIPythonHome /root/epd-5.1.0
该值应对应于运行时从Python打印的sys.prefix的值。
import sys
print sys.prefix
答案 1 :(得分:0)
根据您所得到的错误,似乎可能会发生一些事情。然而,我不会把所有这些都投入到评论中,而是继续作为答案发布。
在我的django.wsgi文件中,我有以下两行更改PATH环境变量,让python从我的django项目导入包:
import sys
sys.path.append('/path/to/mysite.com/app/mydjangoproject')
您还需要确保在httpd.conf
内的VirtualHost
中添加以下内容,您将使用django:
<Directory /path/to/mysite.com/app/mydjangoproject>
Order allow,deny
Allow from all
</Directory>
编辑:
关于您在错误消息中显示的评论中提到的符号链接,我不太清楚该怎么做。如果您只是尝试使用它来允许apache访问DocumentRoot之外的资源,那么您需要为包含符号链接的Options FollowSymLinks
添加Directory
指令