2012-07-14 30 views
5

我是一个noob并在AWS上运行Yii教程。到目前为止,我已经能够启动和运行所有的东西 - 包括mysql连接。但是现在我正在使用Gii代码生成工具来帮助创建一些模型类。在此过程中,我发现了以下错误:Yii/Linux上的Web进程权限

generating models/User.php 
      Unable to write the file '/var/www/html/blog/protected/models/User.php'. 
done! 

的文档还告诉我:

Info: Because the code generator needs to save the generated code into files, it is 
required that the Web process have the permission to create and modify the corresponding 
files. For simplicity, we may give the Web process the write permission to the whole 
/www/blog directory. Note that this is only needed on development machines when using Gii. 

这对我来说很有意义,我理解的Linux权限的基本逻辑应用到用户和组......但不包括进程。有人能指点我如何给Gii进程写入webroot权限(在我的情况下:/ var/www/html/blog /)目录吗?

+0

后执行想补充一点,我已阅读并理解在生产服务器上运行Gii的危险。但是,config/main.php文件中的ip过滤器设置被设置为只允许从我的公共IP地址运行Gii。因此,运行一个实时的AWS实例(而不是WAMP本地主机)似乎仍然是安全的。 – 2012-07-14 07:22:03

+0

进一步更新:我犯了一个错误,试图快速修复,但没有正确理解它,并做了... chmod -R 0644/var/www/html/blog/...我现在无法访问页面,这意味着我已经关闭应用程序。 ... 帮帮我!! – 2012-07-14 07:37:26

+1

套'755'。 '进程'不需要权限,脚本在这种情况下是'Gii'。但是,如果apache在文件夹上有读/写/执行权限(7),它应该可以工作,并允许你在'Gii'配置文件中添加你的IP。 – adamors 2012-07-14 11:37:50

回答

5

Gii使用Web服务器用户产生的进程来读取和写入文件。正是这个用户需要写入文件的权限。在Debian/Ubuntu上,用户是www-data。检查你的操作系统是什么,并为该用户在该文件夹中写入权限。

+0

正如在其他答案中提到的,www数据通常是组(也可能是名称?),所以通过使该组的文件夹应该足够 – spuas 2013-09-24 09:37:30

7

我给予所有用户priverlege递归读取,写入和执行webapp文件。

$sudo chmod -R og=rwx webapp_folder 

并解决了权限问题,但它可能不是最好的方法。

+0

最好将组更改为apache组(通常是www -data'或'www'),并为该组写入权限 – spuas 2013-09-24 09:35:56

0

仅供参考,如果命令文件夹或通过DIR命令创建的一样可以写入文件的用户的浏览器,并同样以反之亦然......但访问了警予写权限..

关注该

sudo chmod -R 0777 your_project_name/ 
+0

该文本没有任何意义。 – Mike 2014-04-05 06:39:56

3

在httpd.conf文件是该行:

# 
# If you wish httpd to run as a different user or group, you must run 
# httpd as root initially and it will switch. 
# 
# User/Group: The name (or #number) of the user/group to run httpd as. 
# It is usually good practice to create a dedicated user and group for 
# running httpd, as with most system services. 
# 
User daemon 
Group daemon 

用户和组的httpd的是“守护”。现在,在终端键入以下命令:

chown -R daemon:daemon /path/to/htdocs/directory 

有时候这个命令必须键入

sudo su 

现在GII可以将文件写入到受保护的文件夹,使用chmod 775个权限