apache apache权限错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/936549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
apache permissions error
提问by
I have an Ubuntu Hardy slice with Passenger Phusion serving up a rails app. I am also using the sphinx full text seach with the thinking_sphinx plugin
我有一个带有Passenger Phusion 的Ubuntu Hardy 切片,提供一个rails 应用程序。我也在使用带有 thinking_sphinx 插件的 sphinx 全文搜索
I can run this command from the terminal:
我可以从终端运行这个命令:
sudo rake ts:index RAILS_ENV=production
须藤耙ts:索引RAILS_ENV =生产
but if this command is in the capistrano deploy file :
但如果此命令在 capistrano 部署文件中:
run "cd #{current_path}; rake thinking_sphinx:index RAILS_ENV=production"
运行 "cd #{current_path}; rake thinking_sphinx:index RAILS_ENV=production"
the following error is generated:
生成以下错误:
- executing `deploy:after_update'
- executing `thinking_sphinx:index'
- executing "cd /home/kollar/apps/kinfonet/current; rake thinking_sphinx:index RAILS_ENV=production" servers: ["173.45.226.102"] [173.45.226.102] executing command * [err :: 173.45.226.102] rake aborted! *[err :: 173.45.226.102] Permission denied - /home/kollar/apps/kinfonet/shared/db/sphinx
- 执行`deploy:after_update'
- 执行`thinking_sphinx:index'
- 执行 "cd /home/kollar/apps/kinfonet/current; rake thinking_sphinx:index RAILS_ENV=production" 服务器:["173.45.226.102"] [173.45.226.102] 正在执行命令 * [err :: 173.45.226.102] *[错误 :: 173.45.226.102] 权限被拒绝 - /home/kollar/apps/kinfonet/shared/db/sphinx
Assuming this was a permissions problem with apache, I followed an article on slicehost docs and did the following:
假设这是 apache 的权限问题,我按照关于 slicehost docs 的文章进行了以下操作:
sudo chgrp -R www-data /home/kollar/apps/kinfonet/current
须藤 chgrp -R www-data /home/kollar/apps/kinfonet/current
sudo chmod -R 2750 /home/kollar/apps/kinfonet/current
须藤 chmod -R 2750 /home/kollar/apps/kinfonet/current
sudo chmod -R 2770 /home/kollar/apps/kinfonet/current/log
须藤 chmod -R 2770 /home/kollar/apps/kinfonet/current/log
sudo chmod -R 2770 /home/kollar/apps/kinfonet/shared
须藤 chmod -R 2770 /home/kollar/apps/kinfonet/shared
sudo chmod -R 2770 /home/kollar/apps/kinfonet/shared/db
须藤 chmod -R 2770 /home/kollar/apps/kinfonet/shared/db
sudo chmod -R 2770 /home/kollar/apps/kinfonet/shared/db/sphinx
须藤 chmod -R 2770 /home/kollar/apps/kinfonet/shared/db/sphinx
sudo chmod -R 2770 /home/kollar/apps/kinfonet/shared/pids
须藤 chmod -R 2770 /home/kollar/apps/kinfonet/shared/pids
THe error is still there and now visitors to the site cannot access their profile pictures which are located in /home/kollar/apps/kinfonet/shared/system/avatars
该错误仍然存在,现在该站点的访问者无法访问位于 /home/kollar/apps/kinfonet/shared/system/avatars 中的个人资料图片
There is an apache/passenger forbidden error if I call up the path to the image on the browser : You don't have permission to access /system/avatars/48/thumb_BR.jpg on this server
如果我在浏览器上调用图像的路径,则会出现 apache/passenger forbidden 错误:您无权访问此服务器上的 /system/avatars/48/thumb_BR.jpg
Can someone help fix the permissions - ie undo whatever I have done with www-data and show me how to set the appropriate permissions?
有人可以帮助修复权限 - 即撤消我对 www-data 所做的一切并告诉我如何设置适当的权限吗?
回答by Steve Madsen
If you're still seeing the 403 Forbidden error, then you need to tell Apache that it's OK to follow that symlink from your app/current/systemto app/shared/system. Ensure you have this in your virtual host definition:
如果您仍然看到 403 Forbidden 错误,那么您需要告诉 Apache 从您app/current/system的app/shared/system. 确保您的虚拟主机定义中有这个:
Options FollowSymLinks
回答by Steve Madsen
Thanks for trying to help.
感谢您尝试提供帮助。
"What user is running the deploy commands on the remote server? " -- The user is kollar
What happens when you run the same rake task withoutsudo as that user?
“哪个用户在远程服务器上运行部署命令?”——用户是 kollar
当您在没有sudo 的情况下作为该用户运行相同的 rake 任务时会发生什么?
got this to work. Ran a ls-l on shared/db and saw that it was set to root as user and root as group. changed both to my user "kollar" and now rake can run from the cap deploy.rb file without sudo.
让这个工作。在 shared/db 上运行 ls-l 并看到它被设置为 root 作为用户和 root 作为组。都更改为我的用户“kollar”,现在 rake 可以从 cap deploy.rb 文件运行而无需 sudo。
My biggest problem remains that apache is bringing back a Forbidden 403 permissions error when it tries to access the shared/system folder where user uploaded images are stored:
我最大的问题仍然是 apache 在尝试访问存储用户上传图像的共享/系统文件夹时,会带回 Forbidden 403 权限错误:
You don't have permission to access /system/avatars/51/thumb_DSC00010.JPG on this server. Apache/2.2.8 (Ubuntu) Phusion_Passenger/2.2.2 Server port 80
您无权访问此服务器上的 /system/avatars/51/thumb_DSC00010.JPG。Apache/2.2.8 (Ubuntu) Phusion_Passenger/2.2.2 服务器端口 80
there is a symlink from /home/path/to/app/current/system to /home/path/to/app/shared/system
有一个从 /home/path/to/app/current/system 到 /home/path/to/app/shared/system 的符号链接
running an ls -l on shared/sytem produces: drwxrws--- 7 kollar kollar 4096 Jun 2 06:47 avatars
在共享/系统上运行 ls -l 会产生:drwxrws--- 7 kollar kollar 4096 Jun 2 06:47 avatars
I tried adding www-data as group on this folder but that doesn't seem to solve the problem. Any help on this would be greatly appreciated.
我尝试将 www-data 作为组添加到此文件夹中,但这似乎并没有解决问题。对此的任何帮助将不胜感激。

