– 設定ファイル
– ログインした時に読み込まれる
– ログインシェルがbashの状態でログインした時に読み込まれる
– bash_profileはログインした直後のホームディレクトリにある
なんかエラーが出ている
[vagrant@localhost rails]$ gem install pg -v ‘1.1.4’
Building native extensions. This could take a while…
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-1.1.4/ext
/home/vagrant/.rbenv/versions/2.3.1/bin/ruby -I /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0 -r ./siteconf20190809-24267-2gatu1.rb extconf.rb
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
checking for libpq-fe.h… no
Can’t find the ‘libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/home/vagrant/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)
–with-pg
–without-pg
–enable-windows-cross
–disable-windows-cross
–with-pg-config
–without-pg-config
–with-pg_config
–without-pg_config
–with-pg-dir
–without-pg-dir
–with-pg-include
–without-pg-include=${pg-dir}/include
–with-pg-lib
–without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-1.1.4 for inspection.
Results logged to /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/gem_make.out
[vagrant@localhost rails]$ find ~/.rbenv | grep mkmf.log
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/msgpack-1.3.1/mkmf.log
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/mkmf.log
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/nio4r-2.4.0/mkmf.log
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/ffi-1.11.1/mkmf.log
/home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/nokogiri-1.10.3/mkmf.log
[vagrant@localhost rails]$ cat /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/mkmf.log
find_executable: checking for pg_config… ——————– no
——————–
find_header: checking for libpq-fe.h… ——————– no
“gcc -o conftest -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-linux -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/home/vagrant/.rbenv/versions/2.3.1/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L/home/vagrant/.rbenv/versions/2.3.1/lib -Wl,-R/home/vagrant/.rbenv/versions/2.3.1/lib -L. -L/home/vagrant/.rbenv/versions/2.3.1/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/home/vagrant/.rbenv/versions/2.3.1/lib -L/home/vagrant/.rbenv/versions/2.3.1/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc”
checked program was:
/* begin */
1: #include “ruby.h”
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
“gcc -E -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0/x86_64-linux -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0/ruby/backward -I/home/vagrant/.rbenv/versions/2.3.1/include/ruby-2.3.0 -I. -I/home/vagrant/.rbenv/versions/2.3.1/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i”
conftest.c:3:22: error: libpq-fe.h: そのようなファイルやディレクトリはありません
checked program was:
/* begin */
1: #include “ruby.h”
2:
3: #include
——————–
え?
ターミナルベースでherokuにログイン
[vagrant@localhost ~]$ heroku –version
heroku/7.27.1 linux-x64 node-v11.14.0
[vagrant@localhost ~]$ heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/browser/54d1a025-4f83-4774-93e8-afe0faba719a
› Warning: Cannot open browser.
heroku: Waiting for login… ⣯
^C
[vagrant@localhost ~]$ heroku login –interactive
heroku: Enter your login credentials
Email:
Herokuを使おう
やっと戻って来ました
toolbeltはCLIのようですね。
https://devcenter.heroku.com/articles/heroku-cli
[vagrant@localhost ~]$ curl https://cli-assets.heroku.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
105 1892 105 1892 0 0 2942 0 –:–:– –:–:– –:–:– 19306
This script requires superuser access.
You will be prompted for your password by sudo.
Your path is missing /usr/local/bin, you need to add this to use this installer.
[vagrant@localhost ~]$ sudo curl https://cli-assets.heroku.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
105 1892 105 1892 0 0 5341 0 –:–:– –:–:– –:–:– 25567
This script requires superuser access.
You will be prompted for your password by sudo.
Your path is missing /usr/local/bin, you need to add this to use this installer.
[vagrant@localhost ~]$ wget https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz
–2019-08-09 00:02:07– https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz
cli-assets.heroku.com をDNSに問いあわせています… 13.32.54.88, 13.32.54.49, 13.32.54.116, …
cli-assets.heroku.com|13.32.54.88|:443 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 301 Moved Permanently
場所: https://cli-assets.heroku.com/heroku-linux-x64.tar.gz [続く]
–2019-08-09 00:02:08– https://cli-assets.heroku.com/heroku-linux-x64.tar.gz
cli-assets.heroku.com:443 への接続を再利用します。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 29106114 (28M) [application/gzip]
`heroku-linux-amd64.tar.gz’ に保存中
100%[==============================================================================>] 29,106,114 1.58M/s 時間 16s
2019-08-09 00:02:24 (1.76 MB/s) – `heroku-linux-amd64.tar.gz’ へ保存完了 [29106114/29106114]
[vagrant@localhost ~]$ ls
centos6 heroku-linux-amd64.tar.gz index.php zend
[vagrant@localhost ~]$ ls
centos6 heroku-linux-amd64.tar.gz index.php zend
[vagrant@localhost ~]$ tar xf heroku-linux-amd64.tar.gz
[vagrant@localhost ~]$ ls
centos6 heroku heroku-linux-amd64.tar.gz index.php zend
[vagrant@localhost ~]$ sed -i -e “/^export PATH$/i PATH=\$HOME/heroku/bin:\$PATH” ~/.bash_profile
[vagrant@localhost ~]$ export PATH=$HOME/heroku-client/bin:$PATH
[vagrant@localhost ~]$ heroku –version
bash: heroku: コマンドが見つかりません
[vagrant@localhost ~]$ export PATH=$HOME/heroku/bin:$PATH
[vagrant@localhost ~]$ heroku –version
heroku/7.27.1 linux-x64 node-v11.14.0
おいおいおい
[vagrant@localhost .ssh]$ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vagrant/.ssh/id_rsa.
Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
The key fingerprint is:
65:0a:17:62:84:01:83:3e:c4:44:43:b5:e1:d0:63:0a vagrant@localhost.localdomain
The key’s randomart image is:
+–[ RSA 4096]—-+
|=B=+.++ . |
|Eo+=+. . . |
|+ oo. . . o |
| + o + |
| . S |
| |
| |
| |
| |
+—————–+
[vagrant@localhost .ssh]$ ls
authorized_keys id_rsa id_rsa.pub
なんか眠くなって来た。
sudo passwd postgres
[vagrant@localhost ~]$ sudo find / -name pg_hba.conf
/var/lib/pgsql/9.6/data/pg_hba.conf
[vagrant@localhost ~]$ sudo cat /var/lib/pgsql/9.6/data/pg_hba.conf
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
[vagrant@localhost ~]$ sudo passwd postgres
ユーザー postgres のパスワードを変更。
新しいパスワード:
よくないパスワード: 辞書の単語に基づいています
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
[vagrant@localhost ~]$ su – postgres
パスワード:
-bash-4.1$ psql
psql (9.6.15)
“help” でヘルプを表示します.
postgres=# \q
-bash-4.1$ exit
logout
来た!事前準備にどれだけ時間かかってるんじゃ、という感じ。
postgresをインストールする
sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-3.noarch.rpm
sudo yum update
sudo yum install postgresql96 postgresql96-server postgresql96-libs
[vagrant@localhost ~]$ rpm -qa | grep postgres
postgresql96-server-9.6.15-1PGDG.rhel6.x86_64
postgresql96-9.6.15-1PGDG.rhel6.x86_64
postgresql96-libs-9.6.15-1PGDG.rhel6.x86_64
[vagrant@localhost ~]$ service postgresql-9.6 initdb
データベースを初期化中: mkdir: ディレクトリ `/var/lib/pgsql’ を作成できません: 許可がありません
[vagrant@localhost ~]$ sudo service postgresql-9.6 initdb
データベースを初期化中: [ OK ]
[vagrant@localhost ~]$ sudo service postgresql-9.6 start
postgresql-9.6 サービスを開始中: [ OK ]
[vagrant@localhost ~]$ service postgresql-9.6 status
postgresql-9.6 (pid 20665) を実行中…
[vagrant@localhost ~]$ chkconfig postgresql-9.6 –list
postgresql-9.6 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[vagrant@localhost ~]$ chkconfig postgresql-9.6 on
この操作を実行するためには権限が十分ではありません。
[vagrant@localhost ~]$ sudo chkconfig postgresql-9.6 on
[vagrant@localhost ~]$ chkconfig postgresql-9.6 –list
postgresql-9.6 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[vagrant@localhost ~]$ su – postgres
パスワード:
su: パスワードが違います
なにいいいいいいいいいいいい
ip a
Address information is displayed for each network device.
[vagrant@localhost public]$ ip a
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 08:00:27:40:17:62 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
inet6 fe80::a00:27ff:fe40:1762/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 08:00:27:65:e0:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.33.10/24 brd 192.168.33.255 scope global eth1
inet6 fe80::a00:27ff:fe65:e05c/64 scope link
valid_lft forever preferred_lft forever
[vagrant@localhost public]$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[vagrant@localhost public]$ rails -v
bash: rails: コマンドが見つかりません
[vagrant@localhost public]$ git –version
git version 1.7.1
[vagrant@localhost public]$ psql –version
bash: psql: コマンドが見つかりません
railsと、psqlのインストールが必要か。
[vagrant@localhost ~]$ gem update –system
gem install rails
[vagrant@localhost ~]$ gem install bundler
Fetching bundler-2.0.2.gem
bundler’s executable “bundle” conflicts with /home/vagrant/.rbenv/versions/2.3.1/bin/bundle
Overwrite the executable? [yN] y
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Installing ri documentation for bundler-2.0.2
Done installing documentation for bundler after 4 seconds
1 gem installed
[vagrant@localhost ~]$ rails -v
Rails 5.2.3
php.ini session.save_handler
/etc/php.ini
[Session] ; Handler used to store/retrieve data. ; http://php.net/session.save-handler session.save_handler = files
session.save_hanlder defines the hanlder to use when saving and retrieving data related to the session. The default is files. Npte that each extension can use its own save_handler.
先ほどElastiCacheで作成したmemcacheのエンドポイントをphp.iniに設定する
;session.save_handler = files ;session.save_path = "/tmp" session.save_handler = "memcached" session.save_path = "php-session.xxxxx.cfg.apne1.cache.amazonaws.com:11211""
続いて動作確認
session_start(); echo "This is Web Server 1<br>"; if (isset($_SESSION["username"])){ echo $_SESSION["username"]; } else { $_SESSION["username"] = "hoge"; }
なるほど、sessionを共有する両方のphp.iniファイルで、エンドポイントを指定して共有しているのね。
$m = new Memcached(); $m->addServer('localhost', 11211); $m->set('foo', 'var',60); var_dump($m->get('foo')); $m->add('hoge', 'fuga', 60); $m->add('hoge', 'piyo', 60); var_dump($m->get('hoge')); $m->flush(); var_dump($m->get('foo'));
memcached
[vagrant@localhost public]$ yum list installed | grep memcached
[vagrant@localhost public]$ yum list installed | grep php
php.x86_64 5.6.40-12.el6.remi @remi-php56
php-cli.x86_64 5.6.40-12.el6.remi @remi-php56
php-common.x86_64 5.6.40-12.el6.remi @remi-php56
php-devel.x86_64 5.6.40-12.el6.remi @remi-php56
php-gd.x86_64 5.6.40-12.el6.remi @remi-php56
php-intl.x86_64 5.6.40-12.el6.remi @remi-php56
php-mbstring.x86_64 5.6.40-12.el6.remi @remi-php56
php-mysqlnd.x86_64 5.6.40-12.el6.remi @remi-php56
php-pdo.x86_64 5.6.40-12.el6.remi @remi-php56
php-pecl-jsonc.x86_64 1.3.10-2.el6.remi.5.6 @remi-php56
php-pecl-jsonc-devel.x86_64 1.3.10-2.el6.remi.5.6 @remi-php56
php-pecl-zip.x86_64 1.15.4-1.el6.remi.5.6 @remi-php56
php-xml.x86_64 5.6.40-12.el6.remi @remi-php56
[vagrant@localhost public]$ php -v
PHP 5.6.40 (cli) (built: Jul 30 2019 11:02:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
[vagrant@localhost public]$ sudo yum search php memcached
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink | 7.6 kB 00:00
* base: ftp.jaist.ac.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.jaist.ac.jp
* remi-safe: ftp.riken.jp
* updates: ftp.jaist.ac.jp
base | 3.7 kB 00:00
epel | 5.3 kB 00:00
epel/primary_db | 6.1 MB 00:05
extras | 3.4 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql56-community | 2.5 kB 00:00
nodesource | 2.5 kB 00:00
remi-safe | 3.0 kB 00:00
updates | 3.4 kB 00:00
============================================= N/S Matched: php, memcached ==============================================
php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php54-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php54-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php55-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php55-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php56-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php56-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php70-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php70-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php71-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php71-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php72-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php72-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php73-php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php73-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php-ZendFramework-Cache-Backend-Libmemcached.noarch : Zend Framework libmemcache cache backend
php-ZendFramework-Cache-Backend-Memcached.noarch : Zend Framework memcache cache backend
Full name and summary matches only, use “search all” for everything.
ElastiCache
ElastiCache is a managed service related to AWS’s in-memory cache.
The cache engine can be selected from Redis and memcached.
There are units of nodes, shards, and clusters.
Node
– cache server
– the smallest unit of ElastiCache
– The performance(memory, CPU, etc.) varies depending on the selected node type.
Sharde
– A group that organizes nodes
– One shard has one primary node(read / write) and 0-5 read replicas (read only)
Cluster
– A group that organizes shards
– A cache engine can be selected for each cluster. Cluster mode can be enabled or disabled.