Apache 上的 Django 具有 Nginx 写入权限
我已经使用 Apache2 + mod_wsgi 设置了 Django。静态文件由 Nginx 提供服务。 Apache运行在81端口,nginx运行在80端口。
我的设置是这样的: MEDIA_ROOT = 'http://localhost/media/' ADMIN_MEDIA_PREFIX = 'http://localhost/media/'
一切看起来都很好。在 https://localhost:81/admin 我可以看到 Django 管理站点及其静态文件。
我用这个模型创建了一个新应用程序: 歌曲类(模型.模型): Song = models.FileField(upload_to='songs')
当我尝试通过管理站点上传文件时,出现以下错误。
/admin/player/song/add/ 处出现 OSError
[Errno 13] 权限被拒绝:'/http:'
请求方法:POST 请求网址: http://localhost:81/admin/player/song/add/ Django 版本:1.3.1 异常类型:OSError 异常值:
如何允许 apache 将更改应用到 nginx
I've set up Django with Apache2 + mod_wsgi. The static Files are served by Nginx. Apache is running on Port 81 and nginx on Port 80.
my settings are like this:
MEDIA_ROOT = 'http://localhost/media/'
ADMIN_MEDIA_PREFIX = 'http://localhost/media/'
Everything looks fine. At https://localhost:81/admin I can see the Django Admin Site with its static files.
I created a new app with this model:
class Song(models.Model):
song = models.FileField(upload_to='songs')
When I try to upload a file over the admin site i get following error.
OSError at /admin/player/song/add/
[Errno 13] Permission denied: '/http:'
Request Method: POST
Request URL: http://localhost:81/admin/player/song/add/
Django Version: 1.3.1
Exception Type: OSError
Exception Value:
How do I allow apache to apply changes to nginx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已将
MEDIA_ROOT
设置为网址。我认为它应该设置为物理位置,我认为 ADMIN_MEDIA_PREFIX 也是如此。我会尝试更改,
您还必须设置媒体文件夹的权限。我认为您需要授予
www-data
写入权限。You've set your
MEDIA_ROOT
to a url. I think it should be set to a physical location, I think the same goes for theADMIN_MEDIA_PREFIX
. I would try changeand
You'll also have to set permissions to the media folder. I think you need to give
www-data
write permissions.