繁体   English   中英

网络应用无法加载,apache2的错误日志中没有错误

[英]web app won't load , no errors in apache2's error log

我有一个在生产环境中运行的codeigniter Web应用程序。 我试图建立一个新的开发箱,并复制了所有文件,并试图使其启动并运行。 到目前为止,这是不行的! 当我提交页面/数据请求时...我得到200 ...,但是json数据没有出现在页面上。

这是正在执行的“小部件”控制器代码:

public function getlocations()
{
    echo("made it here");
    exit;
    $data = $this->rh_model->get_locations();
    header ('Content-Type: application/json; charset=UTF-8');
    echo json_encode($data);    
   // $this->output->enable_profiler(TRUE);
}//getlocations

到目前为止我尝试过的

  1. 如您所见,我一直在研究代码,以查看该方法是否被调用。

  2. 模型方法“ get_locations”调用数据库并请求数据。 我已经从命令提示符中确保可以使用应用程序使用的相同凭据手动连接到数据库-定义在我的/var/www/html/rhAPI/application/config/database.php文件中。

  3. 这是/var/log/apache2/access.log显示的内容:

127.0.0.1--[10 / Dec / 2014:11:16:13 -0500]“ GET /rhAPI/index.php/widgets/getlocations HTTP / 1.1” 200225“-”“ Mozilla / 5.0(X11; Linux x86_64 )AppleWebKit / 537.36(KHTML,例如Gecko)Chrome / 39.0.2171.71 Safari / 537.36“ 127.0.0.1--[10 / Dec / 2014:11:16:28 -0500]” GET /rhAPI/index.php/widgets/ getlocations HTTP / 1.1“ 200 225”-“” Mozilla / 5.0(X11; Ubuntu; Linux x86_64; rv:34.0)Gecko / 20100101 Firefox / 34.0“

  1. apache2错误日志中没有任何内容。

  2. 我的浏览器调试工具中的“网络”部分在“标题”选项卡中显示200 OK状态代码,但“响应”选项卡为空。

  3. 文件权限。 我确保我所有的文件夹都有755个文件,文件有644个。我不认为这是一个权限问题,因为当我故意不正确地设置权限时,权限错误确实会显示在网页上。 我的php.ini设置设置为显示错误,显示所有错误消息。

我不确定还能检查什么。 任何建议,将不胜感激。

编辑1

我只是在开发箱上尝试过此测试:

  1. 在/ var / www / html下创建一个名为“ test”的新文件夹
  2. 使用以下代码创建一个名为phpinfo.php的新php文件:

  3. 试图导航到localhost / test / phpinfo.php,但我也没有得到任何帮助。

现在我怀疑apache2已设置...正在检查...

编辑2

我在模型的构造函数中添加了以下条目

      public function __construct()
      {
          echo("in the constructor");
          parent::__construct();
          $this->load->database();
          echo("loaded");
      }       

打印第一个调试语句,但不打印第二个。 这是我在database.php中拥有的东西:

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'test1234';
$db['default']['database'] = 'testdb';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

这是我通过命令行执行的操作,以测试数据库连接是否正常运行:

me@medev:/var/www/html/rhAPI/application/models$ mysql -u root -p testdb
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.6.19-1~exp1ubuntu2 (Ubuntu)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

我是个白痴。 我在此新服务器上缺少php5 mysql驱动程序/软件包。 我不得不 :

sudo apt-get install php5-mysql
sudo service apache2 restart

我所有的问题都消失了。 对不起,噪音。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM