152 lines
3.4 KiB
Markdown
152 lines
3.4 KiB
Markdown
|
+++
|
||
|
date = "2019-04-01"
|
||
|
tags = ["cachet","icloud"]
|
||
|
title = "ibmcloudでcachetを立てる"
|
||
|
slug = "cachet"
|
||
|
+++
|
||
|
|
||
|
|
||
|
[CachetHQ/Cachet](https://github.com/CachetHQ/Cachet) on [bluemix](https://console.au-syd.bluemix.net)(ibm cloud).
|
||
|
|
||
|
cachetというappをibm cloudで動かす手順を記録します。
|
||
|
|
||
|
```sh
|
||
|
$ git clone https://github.com/CachetHQ/Cachet
|
||
|
# masterでは、bootstrap/autoload.phpのerrorが出るため特定のcommitまで戻す。おそらく原因は、secrity updateの"Bump bootstrap-sass from 3.4.0 to 3.4.1"です
|
||
|
$ git reset --hard b82651f7943619ebc9df46dd5ebbe14f809791d8
|
||
|
|
||
|
$ cp .env.example .env
|
||
|
|
||
|
# myslqDBが必要になる
|
||
|
$ heroku create $APP_NAME
|
||
|
$ heroku addons:add cleardb:ignite -a $APP_NAME
|
||
|
$ heroku config -a $APP_NAME
|
||
|
|
||
|
$ vim .env
|
||
|
APP_URL=https://$APP_NAME_BLUEMIX.mybluemix.net
|
||
|
DB_DRIVER=mysql
|
||
|
DB_HOST=$DB_HOST
|
||
|
DB_UNIX_SOCKET=null
|
||
|
DB_DATABASE=$DB_NAME
|
||
|
DB_USERNAME=$DB_USER
|
||
|
DB_PASSWORD=$DB_PASS
|
||
|
DB_PORT=3306
|
||
|
DB_PREFIX=null
|
||
|
CACHE_DRIVER=file
|
||
|
SESSION_DRIVER=file
|
||
|
QUEUE_DRIVER=sync
|
||
|
|
||
|
$ vim .bp-config/options.json
|
||
|
{
|
||
|
"COMPOSER_INSTALL_OPTIONS_DEBUG": [ "--no-dev", "-o"],
|
||
|
"PHP_VERSION": "{PHP_71_LATEST}",
|
||
|
"COMPOSER_VENDOR_DIR": "vendor",
|
||
|
"WEBDIR": "public",
|
||
|
"PHP_EXTENSIONS": ["bz2", "pdo", "zlib", "curl", "mcrypt", "mbstring", "mysqli", "gd", "zip", "pdo_mysql", "pdo_sqlite","iconv", "openssl" ]
|
||
|
}
|
||
|
|
||
|
$ vim manifest.yml
|
||
|
applications:
|
||
|
- path: .
|
||
|
name: cachet
|
||
|
memory: 256M
|
||
|
command: null
|
||
|
buildpack: https://github.com/cloudfoundry/php-buildpack
|
||
|
|
||
|
$ mkdir htdocs
|
||
|
$ mv database htdocs/
|
||
|
|
||
|
$ php -v
|
||
|
7.1.27
|
||
|
|
||
|
# 修正箇所を示します。
|
||
|
$ vim composer.json
|
||
|
"require": {
|
||
|
+ "php": "7.1.27"
|
||
|
}
|
||
|
"autoload": {
|
||
|
"classmap": [
|
||
|
+ "htdocs/database"
|
||
|
]
|
||
|
}
|
||
|
"config": {
|
||
|
"platform": {
|
||
|
+ "php": "7.1.27"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$ php artisan key:generate
|
||
|
$ php artisan migrate --force
|
||
|
|
||
|
$ cf login
|
||
|
$ cf api https://api.ng.bluemix.net
|
||
|
$ cf target
|
||
|
$ cf target -o $USER -s dev
|
||
|
$ vim .gitignore
|
||
|
- .env
|
||
|
|
||
|
$ composer install --no-dev -o
|
||
|
$ composer update
|
||
|
|
||
|
# previewする
|
||
|
$ cd public
|
||
|
$ php -S localhost:8000
|
||
|
$ php artisan up
|
||
|
$ php artisan down
|
||
|
|
||
|
$ git add .
|
||
|
$ git commit -m "first"
|
||
|
$ cf push $APP_NAME_BLUEMIX
|
||
|
```
|
||
|
|
||
|
## 参照
|
||
|
|
||
|
`.bp-config/options.json` : https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html
|
||
|
|
||
|
cachet docs : https://docs.cachethq.io/docs/installing-cachet
|
||
|
|
||
|
## ヒント
|
||
|
|
||
|
### bluemix上でmigrateが失敗する
|
||
|
|
||
|
おそらく、`PHP_EXTENSIONS": [ "mysqli", "pdo_mysql ]`あたりを追加すると行けると思います。
|
||
|
|
||
|
### 問題を調査する
|
||
|
|
||
|
```sh
|
||
|
# buildpackを使ってdeployは正常に完了する場合
|
||
|
$ cf ssh $APP_NAME_BLUEMIX
|
||
|
$ HOME=/home/vcap/app source app/.profile.d/finalize_bp_env_vars.sh
|
||
|
$ php -v
|
||
|
|
||
|
# web server関連のlogを表示する
|
||
|
$ cf logs $APP_NAME_BLUEMIX --recent
|
||
|
|
||
|
# オプションを有効にする
|
||
|
$ cf set-env $APP_NAME_BLUEMIX OPTIMIZE_MEMORY true
|
||
|
|
||
|
# deployする際に、詳細にlogを表示する
|
||
|
$ cf set-env $APP_NAME_BLUEMIX BP_DEBUG true
|
||
|
or
|
||
|
$ ibmcloud app env-set cachet BP_DEBUG true
|
||
|
```
|
||
|
|
||
|
### issueを読む
|
||
|
|
||
|
問題が発生したとき、こちらにissueを書きました。参考になるかもしれません。
|
||
|
|
||
|
https://github.com/cloudfoundry/php-buildpack/issues/295
|
||
|
|
||
|
### php.ini
|
||
|
|
||
|
おそらく、このあたりが参考になると思います。
|
||
|
|
||
|
```sh
|
||
|
$ cf ssh $APP_NAME_BLUEMIX
|
||
|
$ vi ~/app/php/etc/php.ini
|
||
|
```
|
||
|
|
||
|
https://github.com/cloudfoundry/php-buildpack/blob/master/defaults/config/php/7.1.x/php.ini
|
||
|
|
||
|
|