Welcome Guest, Not a member yet? Register   Sign In
Problems after transferring to new server
#1

[eluser]hoyer801[/eluser]
I recently transferred a site from one server to a new one and now I can't get my login form to work. The old server was CentOS/Plesk and the new one is Ubuntu 12.04/Virtualmin using fastcgi. The only change I made to the code was a slight change to the .htaccess that was required to get CI to work on fastcgi.

When you visit the login page on the new server and enter credentials, whether correct or incorrect, you are redirected back to the login page with no error message. On the old server, you get either the logged in page or an error message about incorrect credentials.

The server logs are identical between the two, but I found a difference in the CI logs.

CI log for old the server (this one works):

Quote:DEBUG - 2012-05-24 02:16:24 --> Config Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Hooks Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Utf8 Class Initialized
DEBUG - 2012-05-24 02:16:24 --> UTF-8 Support Disabled
DEBUG - 2012-05-24 02:16:24 --> URI Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Router Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Output Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Security Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Input Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Global POST and COOKIE data sanitized
DEBUG - 2012-05-24 02:16:24 --> Language Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Loader Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Helper loaded: url_helper
DEBUG - 2012-05-24 02:16:24 --> Helper loaded: form_helper
DEBUG - 2012-05-24 02:16:24 --> Helper loaded: html_helper
DEBUG - 2012-05-24 02:16:24 --> Helper loaded: text_helper
DEBUG - 2012-05-24 02:16:24 --> Database Driver Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Session Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Helper loaded: string_helper

DEBUG - 2012-05-24 02:16:24 --> Session routines successfully run
DEBUG - 2012-05-24 02:16:24 --> Jquery Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Javascript Class Initialized and loaded. Driver used: jquery
DEBUG - 2012-05-24 02:16:24 --> Model Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Model Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Model Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Model Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Model Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Email Class Initialized
DEBUG - 2012-05-24 02:16:24 --> Controller Class Initialized


DEBUG - 2012-05-24 02:16:24 --> Form Validation Class Initialized
DEBUG - 2012-05-24 02:16:24 --> File loaded: application/views/includes/header.php
DEBUG - 2012-05-24 02:16:24 --> File loaded: application/views/includes/footer.php
DEBUG - 2012-05-24 02:16:24 --> File loaded: application/views/login.php
DEBUG - 2012-05-24 02:16:24 --> Final output sent to browser
DEBUG - 2012-05-24 02:16:24 --> Total execution time: 0.0820

The new server the lines are identical up until the point where the Form Validation Class is initialized. Instead of that, all I get is this:
Quote:DEBUG - 2012-05-24 09:03:40 --> Controller Class Initialized
ERROR - 2012-05-24 09:03:40 --> 404 Page Not Found -->

If anyone could give me some suggestions on what I should do here, I would be most grateful.

#2

[eluser]weboap[/eluser]
what does your Apache error_log say in your Ubuntu ? and can you post your .htaccess you said you made some adjustments to it
#3

[eluser]hoyer801[/eluser]
my .htaccess:
Code:
php_value display_errors 1
php_value session.bug_compat_42 1
php_value date.timezone "America/Los_Angeles"
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

The only change I made was adding the ? in the last line.

The apache error_log doesn't have anything for this.

#4

[eluser]weboap[/eluser]
try this .htaccess

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ index.php?/$1 [L]

also check your sessions / server time

and post some code from the controller that you are initializing.

#5

[eluser]hoyer801[/eluser]
I tried that .htaccess, but no changes.

Here's the relevant controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
        public function __construct(){
                parent::__construct();
        }
  
        public function index( $success = false, $url = '' ){
                $this->load->library('form_validation');
                if($success) {
                $this->site_model->show_msg_on_payment();
               }
                $data = array('form_attributes' => array('name' => 'frmSignIn', 'id' => 'frmSignIn'),
                                          'script_head' => $this->javascript->compile(),
                                          'redirect' => str_replace(':', '/', $url),
                                          'error' => $this->session->flashdata('error'));

                $this->form_validation->set_message('required', 'please enter %s.');
                $this->form_validation->set_error_delimiters('<span class="error">', '</span>');

                $rules =array( array(
                                        'field'   => 'txtEmail',
                    'label'   => 'username',
                    'rules'   => 'required'
                ),
                                array(
                                        'field'   => 'txtPassword',
                    'label'   => 'password',
                    'rules'   => 'required'
                ));

    $this->form_validation->set_rules($rules);
                if ($this->form_validation->run()){
                    $redirect = $this->input->post("redirect");
                    if($this->user_model->user_validate()) {
                        if(isset($redirect) && $redirect != '') {
                            redirect($redirect);
                        }
                                redirect('profile');
                        }  else {
                                redirect('login');
                        }
                }
                $this->load->view('login', $data);
        }

        public function url($url = '') {
                $this->index(false, $url);
        }
   public function succ() {
                $status = FALSE;
                if($this->input->post('custom') != '') {
                        $status = TRUE;
                }
                $this->index($status);
        }

        public function logout() {
               $this->session->sess_destroy();
                redirect('login');
        }
}

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

As far as server/sessions time, I don't really know much about sessions. The old server was in Mountain time zone, the new is in Pacific.
#6

[eluser]weboap[/eluser]
nothing unusual in your code. quick question
can you

Code:
print $_SERVER['DOCUMENT_ROOT'];
in both servers and post the result? also check your structure folders permissions
#7

[eluser]hoyer801[/eluser]
Document root for new server:
/home/username/public_html

Document root for old server:
/var/www/vhosts/domainname.com/httpdocs

I used rsync to copy the files over, so the permissions should all be the same. I'll double check though.
#8

[eluser]Aken[/eluser]
It sounds more like the session isn't sticking rather than an environment issue (login successful, tries to redirect to actual page, sees no valid session, sends you back to login). Check your cookie settings and such.
#9

[eluser]hoyer801[/eluser]
You were right, it was cookies.

The path for $config['cookie_path'] in application/config/config.php did not exist on the new server. I updated it and now I'm back in business.

Thanks so much for the help.




Theme © iAndrew 2016 - Forum software by © MyBB