如何从 godaddy 运行 控制台 php 使用 codeigniter 订购

how to run from godaddy a console php order with codeigniter

对不起我的英语。我搜索了大约 2 天没有答案。 问题是:

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

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

我得到:

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?/ [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?/ [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^(.+)/$
    RewriteRule ^(.+)/$  / [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  !^(index.php|css|js|images|robots.txt)
    RewriteRule ^(.*)$ /index.php?/ [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?/ [L]

但我的网站运行正在完美运行,我不知道是否删除这些行。

我必须做什么?

谢谢!

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

wget http://www.example.com/mycontroller/mymethod 

在我的例子中:

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

而且效果很好。我不明白的是,为什么 goddady 不把这个简单的信息放在他的 cron 作业面板中。