After setting up cakephp on aws using elastic beanstalk using the guide and everything was worked perfectly except for the following warning.
Warning (2): session_start(): open(/var/lib/php/5.5/session/sess_5keql5k987qets4sni1ji44fj3, O_RDWR) failed: Permission denied (13) [CORE/Cake/Model/Datasource/CakeSession.php, line 628]
I don't understand what I've done wrong. If you've ever used cakephp on aws, please also mention if there are more problems that I might face later on or if I should switch to another hosting site. Thanks.
It has nothing do do with AWS. The current web server user does not have permission to write to the session storage location. To fix it you need to do one of the following.
You can either change the folder permission to allow writing or change the session.save_path
setting in php.ini.
session.save_path
can also be changed in your code via ini_set
or with session_save_path()
, but you should do that before you start a session.
Although the others answers make perfect sense and would work, my need was much simpler. I wanted to modify php configuration files and I found that these replies on aws's forum - especially the one by alvarolb answered my question perfectly.
He found that the configuration /etc/httpd/conf.d/php.conf contained a line that was overriding the php_value session.save_path to "/var/lib/php/session". A simple comment to that line and sessions work perfectly.
All what you need to do it's a save session in database.
Go to /app/Config/core.php and
Change / Add
Configure::write('Session', array(
'defaults' => 'php'
));
to
Configure::write('Session', array(
'defaults' => 'database'
));
2. Create table:
CREATE TABLE IF NOT EXISTS `cake_sessions` (
`id` varchar(255) NOT NULL,
`data` text,
`expires` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Thats it. Now your session saving in database, and you don't need change php.ini or give some permissions.