• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REST server problems in Amazon EC2

I have a CI 3 REST project in my Vagrant machine using the box opifer/ubuntu-php7. Everything works fine in my development environment, but not in my Amazon EC2 servers.

I have two free-tier instances:
  • Ubuntu Server 16.04 LTS (HVM)
  • Ubuntu Server 14.04 LTS (HVM)
I installed Git, cloned the project and installed depencies via composer in both servers. And also created the config.php and database.php files correctly.

  1. The first problem I had was about case sensitive in the name of some libraries. I have some libraries named as WhateverLibrary.php that wasn't being found by the loader. I don't know why I didn't have this problem in my development environment. I solved this by changing the /system/core/Loader.php, doing:

    PHP Code:
    protected function _ci_load_library($class$params NULL$object_name NULL)
       // ...

       //$class = ucfirst($class);
       $class ucfirst(str_replace('library''Library'$class)); // workaround to fix prod bug

       // ...

  2. The problem I'm facing now is about HTTP Verbs. I have a login_post() function called by the login form, but when I submit the form the server is returning "Unknow method".
    After debugging CI 3 core code I got to know that $this->server('REQUEST_METHOD') is returning GET instead of POST in function method() of /system/coreInput.php.

Why this is happening and how to solve this?
And also, am I missing something in my setup? Because I'm having weird problems that I didn't have in my development environment, and the code is the same!

This is my form:
<form id="formLogin" style="margin-top: 5px;" name="formLogin" method="post" action="<?php echo site_url('login_home/login');?>">
   <div id="loginFields">
       <div class="row">
           <div class="col-md-4" style="padding: 0; margin-right: 10px;">
               <input type="email" id="login" name="login" placeholder="E-mail" class="form-control" required="required" />
           <div class="col-md-3" style="padding: 0; margin-right: 10px;">
               <input type="password" id="password" name="password" placeholder="Password" class="form-control" required="required"/>
           <div id="contentLogin" class="col-md-4" style="padding: 0;">
               <input type="submit" id="loginSubmit" name="loginSubmit" value="Enter" class="btn btn-primary"/>
           <div class="col-md-12">
               <a data-toggle="modal" data-target="#forgot_password_modal" href="#" style="color: #888686;font-size: 11px;margin-left: 124px;">forgot password</a>

And here is my controller:
PHP Code:
class Auth extends REST_Controller
   function __construct()

   public function login_post()
       $this->input->post(); // does not work

   public function login_get()
       $this->input->get(); // work!


Nevermind, I got the solution!

This was happening just because I forgot to enable mod_rewrite in my Apache.

This fixes the problem:

sudo a2enmod rewrite
sudo service apache2 restart

An XML error document as the response body

Content-Type: application/xml

An appropriate 3xx, 4xx, or 5xx HTTP status code

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.