following the installation of CakePHP 2.0 (modified, I said that I get the same problem on a clean install of cakephp 2.0) I found myself facing an error I have not been able to solve.
configuration:
server : debian weezy 7
user : test
structure : /wwwjail/siteroot/test/htdocs/[app/...]
nginx configuration
cat /etc/nginx/sites-available/test
server {
listen IP:80 default;
server_name domain.fr;
access_log /var/log/nginx/test.access.log;
error_log /var/log/nginx/test.error.log;
autoindex off;
index index.php index.html;
root /wwwjail/siteroot/test/htdocs/;
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
fastcgi_pass unix:/wwwjail/siteroot/test/php-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
}
}
php5-fpm configuration
cat /etc/php5/fpm/pool.d/test.conf
[test]
listen = /wwwjail/siteroot/test/php-fpm.sock
chroot = /wwwjail/siteroot/test/htdocs
user = test
group = test
listen.allowed_clients = 127.0.0.1
listen.owner = test
listen.group = test
listen.backlog = -1
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 200
pm.status_path = /status_31337
request_terminate_timeout = 30s
catch_workers_output = yes
php_value[session.save_path] = /tmp
Visible errors on the page:
Database connection "Mysql" is missing, or could not be created.
Error: An Internal Error Has Occurred.
Stack Trace
ROOTlibROOTCakeROOTModelROOTDatasourceROOTDboSource.php line 262 → Mysql->connect()
ROOTlibROOTCakeROOTModelROOTConnectionManager.php line 107 → DboSource->__construct(array)
ROOTlibROOTCakeROOTModelROOTModel.php line 3221 → ConnectionManager::getDataSource(string)
ROOTlibROOTCakeROOTModelROOTModel.php line 1108 → Model->setDataSource(string)
ROOTlibROOTCakeROOTModelROOTModel.php line 3243 → Model->setSource(string)
ROOTlibROOTCakeROOTModelROOTModel.php line 2696 → Model->getDataSource()
ROOTappROOTControllerROOTAppController.php line 70 → Model->find(string, array)
ROOTappROOTControllerROOTChallengesController.php line 57 → AppController->beforeFilter()
[internal function] → ChallengesController->beforeFilter(CakeEvent)
ROOTlibROOTCakeROOTEventROOTCakeEventManager.php line 248 → call_user_func(array, CakeEvent)
ROOTlibROOTCakeROOTControllerROOTController.php line 670 → CakeEventManager->dispatch(CakeEvent)
ROOTlibROOTCakeROOTRoutingROOTDispatcher.php line 184 → Controller->startupProcess()
ROOTlibROOTCakeROOTRoutingROOTDispatcher.php line 162 → Dispatcher->_invoke(ChallengesController, CakeRequest, CakeResponse)
ROOTappROOTwebrootROOTindex.php line 109 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOTindex.php line 43 → require(string)
CakePHP: the rapid development php framework
Nginx Error log nginx :
2013/12/24 12:23:03 [error] 17792#0: *535 open() "/wwwjail/siteroot/test/htdocs/css/default.css" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /css/default.css HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *536 open() "/wwwjail/siteroot/test/htdocs/css/bootstrap.css" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /css/bootstrap.css HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *537 open() "/wwwjail/siteroot/test/htdocs/css/jqplot.css" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /css/jqplot.css HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *538 open() "/wwwjail/siteroot/test/htdocs/js/jqplot.js" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /js/jqplot.js HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *534 open() "/wwwjail/siteroot/test/htdocs/js/holder.js" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /js/holder.js HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *531 open() "/wwwjail/siteroot/test/htdocs/css/cake.generic.css" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /css/cake.generic.css HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *531 open() "/wwwjail/siteroot/test/htdocs/img/cake.power.gif" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /img/cake.power.gif HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *535 open() "/wwwjail/siteroot/test/htdocs/js/jqplot.js" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /js/jqplot.js HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *531 open() "/wwwjail/siteroot/test/htdocs/js/holder.js" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /js/holder.js HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *531 open() "/wwwjail/siteroot/test/htdocs/css/cake.generic.css" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /css/cake.generic.css HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
2013/12/24 12:23:03 [error] 17792#0: *531 open() "/wwwjail/siteroot/test/htdocs/img/cake.power.gif" failed (2: No such file or directory), client: myIP, server: domain.fr, request: "GET /img/cake.power.gif HTTP/1.1", host: "IP:80", referrer: "http://IP:80/"
On the mysql database credentials are correct, the user mysql user-test exist and full access to test.*
cat /wwwjail/siteroot/test/htdocs/app/Config/database.php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => '127.0.0.1',
'login' => 'user-test',
'password' => 'mypassword',
'database' => 'test',
'prefix' => '',
'encoding' => 'utf8'
);
}
Checking the connection with the config file of CakePHP (script found on stackoverflow)
<?php
include("app/Config/database.php");
$config= new DATABASE_CONFIG();
$name = 'default';
$settings=$config->{$name};
$dsn = 'mysql:dbname='.$settings['database'].';host='.$settings['host'];
$user = $settings['login'];
$password = $settings['password'];
try {
$dbh = new PDO($dsn, $user, $password);
echo "Connection succeeded with dsn: ". $dsn . "\n";
$sql = 'SELECT id, title FROM posts';
echo "Here is the contents of the table `posts:";
foreach ($dbh->query($sql) as $row) {
print $row['id'] . "\t" . $row['title'] . "\n";
}
} catch (PDOException $e) {
echo 'PDO error: ' . $e->getMessage();
}
?>
====> return: Connection succeeded with dsn: mysql:dbname=test;host=127.0.0.1 Here is the contents of the table
posts:`
Checking socket with php.ini
*grep -i 'default_socket' /etc/php5/fpm/php.ini*
default_socket_timeout = 60
pdo_mysql.default_socket= /wwwjail/var/run/mysqld/mysqld.sock
mysql.default_socket = /wwwjail/var/run/mysqld/mysqld.sock
mysqli.default_socket = /wwwjail/var/run/mysqld/mysqld.sock
Verification of the existence of the PDO extension.
var_dump( extension_loaded('pdo_mysql') );
return => bool(true)
I hope I have provided much information about my problem. I am willing to perform various manipulations to test. (I think a problem server side configuration necessarily, although this configuration works for other basic applications connecting to mysql also).
Sincerely.
In your /app/Config/database.php file, change the following line:
'host' => 'localhost',
to:
'host' => '127.0.0.1',