質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

CakePHP

CakePHPは、PHPで書かれたWebアプリケーション開発用のフレームワークです。 Ruby on Railsの考え方を多く取り入れており、Railsの高速性とPHPの機動性を兼ね備えています。 MVCやORMなどを「規約優先の考え方」で利用するため、コードを書く手間を省くことができます。 外部のライブラリに依存しないので、単体での利用が可能です。

memcached

memcached は、汎用の分散型メモリキャッシュサーバです。

Q&A

0回答

795閲覧

heroku環境でmemcachedのエラー

tunnel

総合スコア30

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

CakePHP

CakePHPは、PHPで書かれたWebアプリケーション開発用のフレームワークです。 Ruby on Railsの考え方を多く取り入れており、Railsの高速性とPHPの機動性を兼ね備えています。 MVCやORMなどを「規約優先の考え方」で利用するため、コードを書く手間を省くことができます。 外部のライブラリに依存しないので、単体での利用が可能です。

memcached

memcached は、汎用の分散型メモリキャッシュサーバです。

0グッド

0クリップ

投稿2019/11/10 04:59

編集2019/11/10 05:26

ローカル環境で開発したwebアプリをherokuにデプロイしたところ、ローカルではできていたログインができなく、herokuのログを見ると以下のエラーが出ていました。

Warning: Warning (512): Cache engine Cake\Cache\Engine\MemcachedEngine is not properly configured. in [/app/vendor/cakephp/cakephp/src/Cache/Cache.php, line 178]

設定がうまくできていないみたいなので、設定ファイルを確認しましたが、どこが違うのか見当がつきません。

herokuのドキュメントを見ていたら、プロトコルの設定?のことが書いてあり、これだと思い実行してみましたが変わりませんでした。

開発環境は以下のお通りです。
centos: 6.10
php: 5.6
cakephp: 3.8

よろしくお願いいたします。

php

1//App/config/app_heroku.php 2<?php 3 4use Cake\Cache\Engine\FileEngine; 5use Cake\Database\Connection; 6use Cake\Database\Driver\Mysql; 7use Cake\Error\ExceptionRenderer; 8use Cake\Log\Engine\FileLog; 9use Cake\Mailer\Transport\MailTransport; 10 11$db = parse_url(env('CLEARDB_DATABASE_URL')); 12 13return [ 14 15 'debug' => false, 16 17 18 'App' => [ 19 'namespace' => 'App', 20 'encoding' => env('APP_ENCODING', 'UTF-8'), 21 'defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'), 22 'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'), 23 'base' => false, 24 'dir' => 'src', 25 'webroot' => 'webroot', 26 'wwwRoot' => WWW_ROOT, 27 //'baseUrl' => env('SCRIPT_NAME'), 28 'fullBaseUrl' => false, 29 'imageBaseUrl' => 'img/', 30 'cssBaseUrl' => 'css/', 31 'jsBaseUrl' => 'js/', 32 'paths' => [ 33 'plugins' => [ROOT . DS . 'plugins' . DS], 34 'templates' => [APP . 'Template' . DS], 35 'locales' => [APP . 'Locale' . DS], 36 ], 37 ], 38 39 40 'Security' => [ 41 'salt' => env('SALT'), 42 ], 43 44 45 'Asset' => [ 46 //'timestamp' => true, 47 // 'cacheTime' => '+1 year' 48 ], 49 50 /** 51 * Configure the cache adapters. 52 */ 53 'Cache' => [ 54 'default' => [ 55 'className' => 'Memcached', 56 'prefix' => 'myapp_cake_', 57 'servers' => [env('MEMCACHIER_SERVERS')], 58 'username' => env('MEMCACHIER_USERNAME'), 59 'password' => env('MEMCACHIER_PASSWORD'), 60 'duration' => '+1440 minutes', 61 ], 62 63 'session' => [ 64 'className' => 'Memcached', 65 'prefix' => 'myapp_cake_session_', 66 'servers' => [env('MEMCACHIER_SERVERS')], 67 'username' => env('MEMCACHIER_USERNAME'), 68 'password' => env('MEMCACHIER_PASSWORD'), 69 'duration' => '+1440 minutes', 70 ], 71 72 '_cake_core_' => [ 73 'className' => 'Memcached', 74 'prefix' => 'myapp_cake_core_', 75 'servers' => [env('MEMCACHIER_SERVERS')], 76 'username' => env('MEMCACHIER_USERNAME'), 77 'password' => env('MEMCACHIER_PASSWORD'), 78 'duration' => '+1 years', 79 ], 80 81 '_cake_model_' => [ 82 'className' => 'Memcached', 83 'prefix' => 'myapp_cake_model_', 84 'servers' => [env('MEMCACHIER_SERVERS')], 85 'username' => env('MEMCACHIER_USERNAME'), 86 'password' => env('MEMCACHIER_PASSWORD'), 87 'duration' => '+1 years', 88 ], 89 ], 90 91 92 'Error' => [ 93 'errorLevel' => E_ALL & ~E_USER_DEPRECATED, 94 'exceptionRenderer' => ExceptionRenderer::class, 95 'skipLog' => [], 96 'log' => true, 97 'trace' => true, 98 ], 99 100 101 'EmailTransport' => [ 102 'default' => [ 103 'className' => MailTransport::class, 104 /* 105 * The following keys are used in SMTP transports: 106 */ 107 'host' => 'localhost', 108 'port' => 25, 109 'timeout' => 30, 110 'username' => null, 111 'password' => null, 112 'client' => null, 113 'tls' => null, 114 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), 115 ], 116 ], 117 118 119 'Email' => [ 120 'default' => [ 121 'transport' => 'default', 122 'from' => 'you@localhost', 123 //'charset' => 'utf-8', 124 //'headerCharset' => 'utf-8', 125 ], 126 ], 127 128 129 'Datasources' => [ 130 'default' => [ 131 'className' => 'Cake\Database\Connection', 132 'driver' => 'Cake\Database\Driver\Mysql', 133 'persistent' => false, 134 'host' => $db['host'], 135 'username' => $db['user'], 136 'password' => $db['pass'], 137 'database' => substr($db['path'], 1), 138 'encoding' => 'utf8', 139 'timezone' => '+9:00', 140 'cacheMetadata' => true, 141 'quoteIdentifiers' => false, 142 ], 143 ], 144 145 /** 146 * Configures logging options 147 */ 148 'Log' => [ 149 'debug' => [ 150 'className' => 'Cake\Log\Engine\ConsoleLog', 151 'stream' => 'php://stdout', 152 'levels' => ['notice', 'info', 'debug'], 153 ], 154 'error' => [ 155 'className' => 'Cake\Log\Engine\ConsoleLog', 156 'stream' => 'php://stderr', 157 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], 158 ], 159 ], 160 161 'Session' => [ 162 'defaults' => 'cache', 163 'handler' => [ 164 'config' => 'session' 165 ] 166 ] 167]; 168

php

1<?php 2//App/config/bootstrap.php 3/* 4 * Configure paths required to find CakePHP + general filepath constants 5 */ 6require __DIR__ . '/paths.php'; 7 8 9require CORE_PATH . 'config' . DS . 'bootstrap.php'; 10 11use Cake\Cache\Cache; 12use Cake\Console\ConsoleErrorHandler; 13use Cake\Core\Configure; 14use Cake\Core\Configure\Engine\PhpConfig; 15use Cake\Core\Plugin; 16use Cake\Database\Type; 17use Cake\Datasource\ConnectionManager; 18use Cake\Error\ErrorHandler; 19use Cake\Http\ServerRequest; 20use Cake\Log\Log; 21use Cake\Mailer\Email; 22use Cake\Mailer\TransportFactory; 23use Cake\Utility\Inflector; 24use Cake\Utility\Security; 25 26 27try { 28 Configure::config('default', new PhpConfig()); 29 Configure::load('app', 'default', false); 30} catch (\Exception $e) { 31 exit($e->getMessage() . "\n"); 32} 33 34 35//Configure::load('app_local', 'default'); 36if (isset($_ENV['CAKE_ENV'])) { 37 Configure::load('app_' . $_ENV['CAKE_ENV'], 'default'); 38} 39 40/* 41 * When debug = true the metadata cache should only last 42 * for a short time. 43 */ 44if (Configure::read('debug')) { 45 Configure::write('Cache._cake_model_.duration', '+2 minutes'); 46 Configure::write('Cache._cake_core_.duration', '+2 minutes'); 47 // disable router cache during development 48 Configure::write('Cache._cake_routes_.duration', '+2 seconds'); 49} 50 51 52date_default_timezone_set('Asia/Tokyo'); 53 54/* 55 * Configure the mbstring extension to use the correct encoding. 56 */ 57mb_internal_encoding(Configure::read('App.encoding')); 58 59 60ini_set('intl.default_locale', Configure::read('App.defaultLocale')); 61 62/* 63 * Register application error and exception handlers. 64 */ 65$isCli = PHP_SAPI === 'cli'; 66if ($isCli) { 67 (new ConsoleErrorHandler(Configure::read('Error')))->register(); 68} else { 69 (new ErrorHandler(Configure::read('Error')))->register(); 70} 71 72/* 73 * Include the CLI bootstrap overrides. 74 */ 75if ($isCli) { 76 require __DIR__ . '/bootstrap_cli.php'; 77} 78 79/* 80 * Set the full base URL. 81 * This URL is used as the base of all absolute links. 82 * 83 * If you define fullBaseUrl in your config file you can remove this. 84 */ 85if (!Configure::read('App.fullBaseUrl')) { 86 $s = null; 87 if (env('HTTPS')) { 88 $s = 's'; 89 } 90 91 $httpHost = env('HTTP_HOST'); 92 if (isset($httpHost)) { 93 Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); 94 } 95 unset($httpHost, $s); 96} 97 98Cache::setConfig(Configure::consume('Cache')); 99ConnectionManager::setConfig(Configure::consume('Datasources')); 100TransportFactory::setConfig(Configure::consume('EmailTransport')); 101Email::setConfig(Configure::consume('Email')); 102Log::setConfig(Configure::consume('Log')); 103Security::setSalt(Configure::consume('Security.salt')); 104 105/* 106 * The default crypto extension in 3.0 is OpenSSL. 107 * If you are migrating from 2.x uncomment this code to 108 * use a more compatible Mcrypt based implementation 109 */ 110//Security::engine(new \Cake\Utility\Crypto\Mcrypt()); 111 112/* 113 * Setup detectors for mobile and tablet. 114 */ 115ServerRequest::addDetector('mobile', function ($request) { 116 $detector = new \Detection\MobileDetect(); 117 118 return $detector->isMobile(); 119}); 120ServerRequest::addDetector('tablet', function ($request) { 121 $detector = new \Detection\MobileDetect(); 122 123 return $detector->isTablet(); 124}); 125 126/* 127 * Enable immutable time objects in the ORM. 128 * 129 * You can enable default locale format parsing by adding calls 130 * to `useLocaleParser()`. This enables the automatic conversion of 131 * locale specific date formats. For details see 132 * @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data 133 */ 134Type::build('time') 135 ->useImmutable(); 136Type::build('date') 137 ->useImmutable(); 138Type::build('datetime') 139 ->useImmutable(); 140Type::build('timestamp') 141 ->useImmutable(); 142

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

nojimage

2019/11/13 05:21

php で memcached拡張は有効ですか?
tunnel

2019/11/14 07:28

herokuのドキュメントにmemcachedは自動で有効になるとの記載がありました。他にも気になることございましたら何なりとご指摘ください。お願いいたします<(__)>
nojimage

2019/11/15 01:23

出ている例外から、memcached拡張が有効でない、memcachedサーバーに接続できていないのいずれかが原因です。確認ですが、MEMCACHIER_SERVERSの環境変数は、適切にセットしていますか?
tunnel

2019/11/15 04:27

heroku configで確認しましたが、セットされていました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問