-1
我需要通過CLI執行php腳本的幫助。不知道這是Linux還是PHP問題。您無權執行此腳本
當我在Ubuntu執行的/ usr/bin中/ PHP /var/www/backup.php我得到:
您不得在備份執行該腳本
代碼.PHP是:
<?php
// Set default paths
define ("DOCUMENT_ROOT","/var/www");
define ("DATABASE_PATH","/var/lib/mysql/livedb");
define ("BACKUP_PATH","/var/sitebackups");
$filename_suffix = "_" . date("Ymd_his") .".tar.gz";
if ($_GET['key']!="xxx") {
die ("You are not permitted to execute this script");
}
//change working directory to backup directory
if (!chdir(BACKUP_PATH)) {
die ("Failed to change to working directory.");
}
// Tar the web files
$cmd = "tar -cvzf " . BACKUP_PATH. "/webfiles" . $filename_suffix . " " .DOCUMENT_ROOT ;
echo $cmd . "<br/>";
//echo shell_exec($cmd);
// Create link to web files backup
// Tar the mysql DB
$cmd = "tar -cvzf " . BACKUP_PATH. "/dbfiles" . $filename_suffix . " " .DATABASE_PATH ;
echo $cmd . "<br/>";
//echo shell_exec($cmd);
// Move to backup folder
// Create link to DB backups
// Email backup confirmation
?>
我甚至試圖通過crontab來補充,這是一個計劃任務,我仍然得到同樣的錯誤在日誌中。
請幫忙!
將?key = xxx添加到URI – jgroenen
您不使用$ _GET作爲CLI腳本 - 此腳本明確寫入要通過Web服務器運行。但只是拿出檢查應該工作 – 2012-11-28 09:20:04
哇,我覺得愚蠢...錯誤是在我的代碼,並且我正在尋找$ _GET而不是$ argv。我希望沒有人知道我發現這篇文章:( –