CakePHP-Fr.Org

Forum francophone du Framework CakePHP

Vous n'êtes pas identifié.

#1 24-12-2013 12:39:02

robs
Chouquette
Date d'inscription: 24-12-2013
Messages: 1

[Prob] Database connection "Mysql" is missing, or could not be created

Bonjour,

suite à l'installation de cakePHP 2.0 (modifié, je précise que j'obtiens le même problème sur une installation vierge de cakephp 2.0) je me suis trouvé face à une erreur que je n'ai pas réussi à résoudre.
Configuration:
serveur debian weezy 7
user : test
structure : /wwwjail/siteroot/test/htdocs/[app/...]

Configuration nginx
cat /etc/nginx/sites-available/test

Code: php

  1. server {
  2.     listen IP:80 default;
  3.     server_name domain.fr;
  4.     access_log /var/log/nginx/test.access.log;
  5.     error_log  /var/log/nginx/test.error.log;
  6.  
  7.     autoindex off;
  8.     index index.php index.html;
  9.     root /wwwjail/siteroot/test/htdocs/;
  10.  
  11.     location ~ \.php$ {
  12.                         try_files $uri =404;
  13.  
  14.                         fastcgi_intercept_errors on;
  15.                         fastcgi_pass unix:/wwwjail/siteroot/test/php-fpm.sock;
  16.  
  17.                         include /etc/nginx/fastcgi_params;
  18.                         fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
  19.     }
  20. }

Configuration php5-fpm
cat /etc/php5/fpm/pool.d/test.conf

Code: php

  1. [test]
  2. listen = /wwwjail/siteroot/test/php-fpm.sock
  3. chroot = /wwwjail/siteroot/test/htdocs
  4.  
  5. user = test
  6. group = test
  7.  
  8. listen.allowed_clients = 127.0.0.1
  9. listen.owner = test
  10. listen.group = test
  11. listen.backlog = -1
  12. pm = dynamic
  13. pm.max_children = 5
  14. pm.start_servers = 2
  15. pm.min_spare_servers = 1
  16. pm.max_spare_servers = 3
  17. pm.max_requests = 200
  18. pm.status_path = /status_31337
  19. request_terminate_timeout = 30s
  20. catch_workers_output = yes
  21. php_value[session.save_path] = /tmp

Erreurs visible sur la page:

Code: php

  1. Database connection "Mysql" is missing, or could not be created.
  2.  
  3. Error: An Internal Error Has Occurred.
  4. Stack Trace
  5.  
  6.     ROOTlibROOTCakeROOTModelROOTDatasourceROOTDboSource.php line 262 → Mysql->connect()
  7.     ROOTlibROOTCakeROOTModelROOTConnectionManager.php line 107 → DboSource->__construct(array)
  8.     ROOTlibROOTCakeROOTModelROOTModel.php line 3221 → ConnectionManager::getDataSource(string)
  9.     ROOTlibROOTCakeROOTModelROOTModel.php line 1108 → Model->setDataSource(string)
  10.     ROOTlibROOTCakeROOTModelROOTModel.php line 3243 → Model->setSource(string)
  11.     ROOTlibROOTCakeROOTModelROOTModel.php line 2696 → Model->getDataSource()
  12.     ROOTappROOTControllerROOTAppController.php line 70 → Model->find(string, array)
  13.     ROOTappROOTControllerROOTChallengesController.php line 57 → AppController->beforeFilter()
  14.     [internal function] → ChallengesController->beforeFilter(CakeEvent)
  15.     ROOTlibROOTCakeROOTEventROOTCakeEventManager.php line 248 → call_user_func(array, CakeEvent)
  16.     ROOTlibROOTCakeROOTControllerROOTController.php line 670 → CakeEventManager->dispatch(CakeEvent)
  17.     ROOTlibROOTCakeROOTRoutingROOTDispatcher.php line 184 → Controller->startupProcess()
  18.     ROOTlibROOTCakeROOTRoutingROOTDispatcher.php line 162 → Dispatcher->_invoke(ChallengesController, CakeRequest, CakeResponse)
  19.     ROOTappROOTwebrootROOTindex.php line 109 → Dispatcher->dispatch(CakeRequest, CakeResponse)
  20.     ROOTindex.php line 43 → require(string)
  21.  
  22. CakePHP: the rapid development php framework

Error log nginx :

Code: php

  1. 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/"
  2. 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/"
  3. 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/"
  4. 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/"
  5. 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/"
  6. 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/"
  7. 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/"
  8. 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/"
  9. 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/"
  10. 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/"
  11. 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/"

Concernant la base mysql, les identifiants sont corrects, l'utilisateur mysql user-test exist et a full access sur test.*

Code: php

  1. class DATABASE_CONFIG {
  2.  
  3.   public $default = array(
  4.     'datasource' => 'Database/Mysql',
  5.     'persistent' => false,
  6.     'host' => '127.0.0.1',
  7.     'login' => 'user-test',
  8.     'password' => 'mypassword',
  9.     'database' => 'test',
  10.     'prefix' => '',
  11.     'encoding' => 'utf8'
  12.   );
  13. }

Vérification de la connexion via le fichier de config de cakePHP ( script trouvé sur stackoverflow )

Code: php

  1. <?php
  2. include("app/Config/database.php");
  3. $config= new DATABASE_CONFIG();
  4.  
  5. $name = 'default';
  6.  
  7. $settings=$config->{$name};
  8. $dsn = 'mysql:dbname='.$settings['database'].';host='.$settings['host'];
  9. $user = $settings['login'];
  10. $password = $settings['password'];
  11.  
  12. try {
  13.     $dbh = new PDO($dsn, $user, $password);
  14.     echo "Connection succeeded with dsn: ". $dsn . "\n";
  15.     $sql = 'SELECT id, title FROM posts';
  16.     echo "Here is the contents of the table `posts:";
  17.     foreach ($dbh->query($sql) as $row) {
  18.         print $row['id'] . "\t" . $row['title'] . "\n";
  19.     }
  20. } catch (PDOException $e) {
  21.     echo 'PDO error: ' . $e->getMessage();
  22. }
  23.  
  24. ?>

====> renvoi :

Code: php

  1. Connection succeeded with dsn: mysql:dbname=test;host=127.0.0.1 Here is the contents of the table `posts:

Vérification des socket via la php.ini :
grep -i  'default_socket' /etc/php5/fpm/php.ini

Code: php

  1.  
  2. default_socket_timeout = 60
  3. pdo_mysql.default_socket= /wwwjail/var/run/mysqld/mysqld.sock
  4. mysql.default_socket = /wwwjail/var/run/mysqld/mysqld.sock
  5. mysqli.default_socket = /wwwjail/var/run/mysqld/mysqld.sock

Vérification de l'existence de l'extension pdo.

Code: php

  1. var_dump( extension_loaded('pdo_mysql') );

===> bool(true)


J'espère avoir fournis un maximum d'information concernant mon problème. Je suis prêt à effectuer diverses manipulations pour tester. ( je pense à un problème coté configuration du serveur forcément, malgré que cette configuration fonctionne pour d'autre applications basiques se connectant elles aussi à mysql ).

Bien cordialement.

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB
Traduction par FluxBB.fr