2015-06-01 37 views
0

我的腳本在plesk最新版本上運行,並且plesk沒有寫入權限。我必須使用數據庫中的值編寫配置文件。php以root用戶身份寫入文件

我嘗試以下,

$pathconn = $_SERVER['DOCUMENT_ROOT']."/mysite/_conn.php"; 
if(file_exists($pathconn)){ 
    chmod($pathconn, 0777); 
} 
$file_contents = file_get_contents($pathconn); 
$file_contents = str_replace("webuser_admin", $username."_admin", $file_contents); 
$file_contents = str_replace("webpass", $mysql_password, $file_contents); 
$file_contents = str_replace("web_db", $username."_ss", $file_contents); 
file_put_contents($pathconn, $file_contents); 

的PHP變量從數據庫快到了,我需要更新_conn.php文件,這些變量來運行網站。由於權限問題,我無法這樣做。

是否有任何其他方式做到這一點?我在某處讀到我們可以將其作爲apacheroot用戶。但我不確定這是什麼意思。幫助請..

+0

我想,這也許鏈接有用你的情況 http://unix.stackexchange.com/questions/35711/giving-php-permission-to-write-to-files-and-folders – Nassim

+0

我不知道如何使用這些命令。 –

+0

你與Plesk卡住了嗎?我沒有使用它,但我沒有問題寫入或使用Apache和cPanel創建新文件,或者我的WAMP設置... –

回答

0

根據您在VPS安裝Linux發行版,你將不得不鍵入不同的命令,但這些措施仍然不變:

1.you必須登錄到你的服務器SSH

2.find您的Web服務器的名稱用戶名

3.Give 權限到與您要的目錄Web服務器(輸入chmod,CHOWN)將數據寫入

相關問題