I have to migrate CakePHP 1.3.0 website which uses PHP 5.6 version, in this case from CPanel to Plesk, I tried using Plesk Migrator extension, for those who don’t know it, it connects to source server and brings everything automatically, but for this website gave me issues. I tried migrating the website manually but I got issues too.
When previewing the website I only get “ERR_TOO_MANY_REDIRECTS” or 302 codes. Researching I found out that this problem could be related to sessions, but I’m not 100% sure that’s the problem.
This is the current core.php
file (I have to censor sensitive info):
<?php
if( isset($_SERVER['REMOTE_ADDR'] ) && ($_SERVER['REMOTE_ADDR'] == 'XX.XXX.XXX.XX' || $_SERVER['REMOTE_ADDR'] ==
'XX.XX.XXX.XXX'))
{
Configure::write('debug', 1);
}
else
Configure::write('debug', 1);
Configure::write('App.encoding', 'UTF-8');
Configure::write('Routing.prefixes', array('admin'));
define('LOG_ERROR', 2);
Configure::write('Session.save', 'php');
Configure::write('Session.cookie', 'CAKEPHP');
Configure::write('Session.timeout', '120');
Configure::write('Session.start', true);
Configure::write('Session.checkAgent', false);
Configure::write('Security.level', 'low');
Configure::write('Security.salt', 'f7e2b4XXXXXXXXXXXXXXXXXXXXXXXXXXeed5a');
Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default');
Cache::config('default', array('engine' => 'File', 'path'=> CACHE, 'duration' => '1 day'));
Configure::write('Cache.disable', true);
Configure::write('Cache.check', true);
Configure::write ('site_env', 'production');
if( isset($_SERVER['REMOTE_ADDR'] ) && ($_SERVER['REMOTE_ADDR'] == 'XX.XX.XXX.XXX'))
Configure::write ('site_env', 'development');
Configure::write( 'App.theme', 'forma');
Configure::write( 'App.mail_form', '[email protected]');
Configure::write ('Google.map_key', 'ABQIAAAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2n7Q');
?>
Looks like this website was using PHP to persist sessions. According to official documentation it saves session files as indicated by php.ini. php.ini default location is session.save_path = "/var/lib/php/session"
, which exists and it has permissions, since other domains are using the same one too. For some reason I don’t understand it’s not working.
The DocumentRoot and the database connection are established, I’m sure because if I remove any of both the website returns different errors.
What can I do to make it work (in case of sessions are the source of the problem)? I don’t mind moving to cake or database sessions if these are easier to configure. In any case I wasn’t able to configure them because I didn’t find many helpful guides.
I changed session.save_path
value to the following one:
/var/www/vhosts/domain.com/httpdocs/tmp/sessions
[root@server02 ~]# ls -lah /var/www/vhosts/domain.com/httpdocs/tmp/
total 16K
drwxr-xr-x 7 formamus psacln 73 abr 6 2020 .
drwxr-x--- 18 formamus psaserv 4,0K ago 13 11:32 ..
drwxrwxrwx 5 formamus psacln 51 abr 6 2020 cache
drwxrwxrwx 2 formamus psacln 26 abr 6 2020 files
drwxrwxrwx 2 formamus psacln 6 abr 6 2020 logs
drwxrwxrwx 2 formamus psacln 8,0K ago 14 10:59 sessions
drwxrwxrwx 2 formamus psacln 6 abr 6 2020 tests
Now session files are being created and saved in the specified path, but the website still gives error 302 (I already tried with different browsers and deleting cache), so I don’t know which is the problem.