2014-03-12 62 views
0

我是一名PHP新手,對事物有所瞭解,但對基本安全概念或服務器管理知之甚少。我最近被黑客入侵(假設從mysql注入),我的文件全部被刪除。試圖恢復正常運行並嘗試正確保護我的腳本後,我遇到了這個問題:賦予文件夾中的文件的PHP根權限

建議我將所有數據庫連接用戶名/密碼等放在一個單獨的.inc文件中單獨的文件夾(不幸的是我需要在根目錄下的一個文件夾中)。我做得很好,但也建議我只給連接文件提供600個文件夾權限。

我的一個數據庫連接文件看起來是這樣的:

$usersusername = "myusername goes here"; 
$userspassword = "64bit encrypted password goes here"; 
$usershostname = "localhost"; 
$usersdbname = "my database goes here"; 

和我包括我的index.php看起來像這樣:

include_once '/dbauth/myloginscript.inc'; 

,我得到的錯誤:

Warning: include_once(/home/mycpaneluser/public_html/dbauth/myloginscript.inc): failed to open stream: Permission denied in /home/mycpaneluser/public_html/index.php on line 60 

Warning: include_once(): Failed opening '/home/mycpaneluser/public_html/dbauth/myloginscript.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myloginscript/public_html/index.php on line 60 

我被告知我需要在http.conf中包含一個允許某種方式的權限,但在我之前ñ得到那麼遠,我遵循正確的程序來保護我的數據庫登錄信息,還是我錯過了標記?任何幫助,將不勝感激。

+0

檢查'config.inc.php'。 – PHPglue

+0

究竟是什麼? – Dustin

+0

確保你的'$ cfg ['Servers'] [$ i] ['user'] ='yourUsername';''和'$ cfg ['Servers'] [$ i] ['password'] ='yourPassword'; '。 – PHPglue

回答

0

確保您的$cfg['Servers'][$i]['user'] = 'yourUsername';$cfg['Servers'][$i]['password'] = 'yourPassword';serverFolder/phpMyAdmin/config.inc.php

0
  1. 追加.PHPmyloginscript.inc(文件名和參考 它),並在文件的最開始添加PHP開始標記,因此 將被PHP解析的是代替顯示爲純文本。如果直接在瀏覽器可訪問的目錄中調用,則最壞情況只需 。
  2. 我假設「root」文件夾實際上就是你的ftp主目錄,在大多數虛擬主機環境中,默認情況下,它是你虛擬主機的文檔根目錄的一級。如果你把你的inc文件放在那裏,參考文件是include_once '../myloginscript.inc.php'; 檢查你的網站主辦的結構和$ _SERVER ['DOCUMENT_ROOT'] var的正確包含路徑。
+0

似乎將文件夾/ dbauth /的權限更改爲770似乎已經工作,無需更改任何http。 conf或任何其他管理文件。我現在的問題是:這足夠安全嗎? – Dustin

+0

更好地確保它正在工作。 ;)如果是,並且通過在域中直接調用inc文件,則應該沒問題。但是,請勿將純文本文件用於登錄憑據,請始終添加.php並用php標記附上php代碼。 – labemi