Toggle navigation
Photo Blog
首页
Blog
关于
作品
联系
Home
About
Contact
Sign in
django部署问题
Posted by
Chris Chen
on April 26, 2017
在使用apache2和wsgi尝试部署django项目时遇到几个问题 #####1. wsgi无法执行, apache错误日志提示wsgi.py没有设置ExecCGI 配置好WSGIScriptAlias和WSGIPythonHome之后发现无法运行,浏览器返回403 ,查看日志说需要设置ExecCGI。设置上之后又说执行错误,文件格式不对。最后明白是.py文件apache当成是cgi,可能直接运行了。于是加上"AddHandler wsgi-script .py"解决. ``` Alias /media/ /data/aso.zhongbosoft.com/mysite/media/ Alias /static/ /data/aso.zhongbosoft.com/mysite/static/ <Directory /data/aso.zhongbosoft.com/mysite/static> Require all granted </Directory> <Directory /data/aso.zhongbosoft.com/mysite/media> Require all granted </Directory> ServerAdmin webmaster@localhost WSGIScriptAlias / /data/aso.zhongbosoft.com/mysite/wsgi.py <Directory /data/aso.zhongbosoft.com/mysite> AddHandler wsgi-script .py <Files wsgi.py> Require all granted </Files> </Directory> ``` #####2. 执行collectstatic出错 因为django无法处理静态文件,所以在apache2的配置上添加静态文件目录。然后按官方的教程,想调用collecstatic来拷贝静态文件。但是执行出错, > You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path stackflow上搜到在settings里面添加这两句 ``` PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') ``` #####3. sqllite数据库写入失败 需要数据库文件所在的文件夹有写权限。。。
0
Comments
Add Comment
Log in
Nick Name
Comment:
Add Comment Log in