2012-07-14 47 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個權限