如何从godaddy运行与codeigniter的控制台PHP命令

时间:2015-05-31 12:24:28

标签: codeigniter cron

抱歉我的英语。我正在搜索大约2天没有答案。 问题是:

我需要运行一个cron作业。我在godaddy中从ssh写入控制台:

/ web / cgi-bin / php5 /path/to/my/project/html/www/myproject/index.php crons test

我得到:

Status: 301 Moved Permanently
Location: http://www.
Content-type: text/html

我在... / application / controllers文件crons.php中有这段代码:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Crons extends MY_Controller {

public function __construct() {
    parent::__construct();
}

public function test() {
    echo "hello word";
}

}

/* End of file crons.php */
/* Location: ./application/controllers/crons.php */

它将转到我的index.php,但它无法正常工作,因为在我的index.php中,我有将此代码重定向到.mysite到www.mysite,而$ getsite_all是错误:

$getsite_all = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$getsite = $_SERVER['HTTP_HOST'];

$getsite = str_replace($e_dom, '', $getsite);

$ugetsite = explode('.', $getsite);
if ($ugetsite[0] != 'www') {
    $estimated_url = 'http://www.' . $getsite_all;
    header('HTTP/1.1 301 Moved Permanently');
    header("Location: $estimated_url");
    die();
}

但是,如果我删除这一行,则错误来自那些行:

// Is the system path correct?
if (!is_dir($system_path)) {
    exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: " . pathinfo(__FILE__, PATHINFO_BASENAME));
}

所以我认为错误可能来自我的.htaccess:

<FilesMatch "\.(css|js|gif|jpe?g|png|ico)$">
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
</FilesMatch>
FileETag none
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /


    # Impide el acceso a la carpeta del sistema
    # "system" se debe cambiar si el nombre la carpeta se modifica.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Esto impide el acceso a la carpeta de la aplicación
    # 'application' se debe cambiar si el nombre la carpeta se modifica.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)/$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^(.+)/$
    RewriteRule ^(.+)/$  /$1 [R=301,L] 

    # Comprueba si el usuario está intentando acceder a un archivo válido,
    # como un documento de imagen o CSS, si esto no es cierto
    # se redirecciona a index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index.php|css|js|images|robots.txt)
    RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

我认为错误可以在:

 RewriteCond %{REQUEST_URI} ^system.*
 RewriteRule ^(.*)$ /index.php?/$1 [L]

但我的网络运行完美,我不知道是否删除此行。

我必须做什么?

谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,这很简单。在godaddy你可以直接放:

wget http://www.example.com/mycontroller/mymethod 
在我的例子中

wget http://www.example.com/crons/test 

它完美无缺。我无法理解的是为什么goddady不会在他的cron工作小组中提供这些简单的信息。