|
发表于 2018-9-26 10:01:14
|
显示全部楼层
试试http://localhost/index。html会显示apache页面吗?如果wsgi在root上配置正确,它就不会。您会得到错误消息,因为您可能正在向webserver询问www文件夹的目录列表
我的项目在
/var/pyproj//pysrc/ and server files i put in /var/py_proj//server/
我的wsgi脚本
import os, sys
import logging
logger =logging.getLogger("")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stderr)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(levelname)-8s %(messages)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
sys.stdout = sys.stderr
from os.path import abspath, dirname, join
import site
PROJECT_ROOT = abspath(join(dirname(__file__), "../pysrc"))
SETTINGS_LOC = abspath(join(PROJECT_ROOT, ''))
site.addsitedir(SETTINGS_LOC)
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
from django.core.management import setup_environ
import settings
setup_environ(settings)
sys.path.insert(0, join(PROJECT_ROOT, "apps"))
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
我用的是vhost.conf
WSGIDaemonProcess pinax_demo user=www-data group=www-data threads=10 python-path=/var/.virtualenvs/pinax_demo/lib/python2.6/site-packages
<Directory /var/py_proj/pinax_demo/server/>
Order deny,allow
Allow from all
</Directory>
Alias /pinax_demo /var/py_proj/pinax_demo/server/pinax_demo.wsgi
<Location /pinax_demo/>
#WSGIProcessGroup must match the WSGIDaemonProcess
WSGIProcessGroup pinax_demo
SetHandler wsgi-script
Options +ExecCGI
</Location>
which i include in the sites-available folder in a file that looks like this
<VirtualHost *:8080>
DocumentRoot /var/www/
<Directory /var/www/>
Order deny,allow
Allow from all
Options -Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride None
</Directory>
LogLevel error
ErrorLog /var/srv_logs/apache_error.log
CustomLog /var/srv_logs/apache_access.log combined
#insert
Include /var/py_proj/pinax_demo/server/vhost.conf
Include /var/py_proj/<other>/server/vhost.conf
Include /var/py_proj/<other>/server/vhost.conf
</VirtualHost>
httpd.conf 是空的,Apache在发送静态文件方面也很糟糕,所以我在端口8080上有Apache设置,在端口80上有nginx设置,它转发给Apache。你应该可以在我的网站上更改端口,在没有nginx的情况下运行它,但我不会那样做 |
|