「プログラミングElixir」を読み返しながら、例題の issues アプリを作ってるんだけど、なんかエラーが出てうまくいかない。
時間もあんまりとれないし、ああもう、めげそう…orz。
投稿者: takatoh
さくらのVPSプラン乗り換え計画(14)
WordPress を旧サーバから移行する。
下準備
旧サーバから新サーバへ、データを移動しておく。Wordpress のデータをディレクトリごと tar でまとめて、データベースは mysqldump で出力した。
ユーザとデータベースを作成
WordPress 用のユーザとデータベースを作成。
[takatoh@tk2-254-36564 ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 46 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'xxxxxxxx'; Query OK, 0 rows affected (0.01 sec) mysql> CREATE DATABASE wpdb; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON wpdb.* TO 'wordpress'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
データベースにデータを復元
今作ったデータベースにデータを復元する。
[takatoh@tk2-254-36564 ~]$ mysql -u wordpress -p wpdb < wpdb.sql Enter password:
WordPressのデータを展開
tar で固めておいた WordPress のデータ一式を /var/www/wordpress に展開する。
[takatoh@tk2-254-36564 ~]$ cd /var/www [takatoh@tk2-254-36564 www]$ sudo cp ~/wordpress.tgz . [sudo] password for takatoh: [takatoh@tk2-254-36564 www]$ sudo tar xzf wordpress.tgz [takatoh@tk2-254-36564 www]$ ls cgi-bin error html icons lathercraft wordpress wordpress.tgz
Nginxにバーチャルホストの設定
/etc/nginx/conf.d/blog2.lathercraft.net.conf ファイルを作る。
server { # port listen 80; # server name server_name blog2.lathercraft.net; # document root root /ver/www/wordpress; # index index index.php; # log files access_log /var/log/nginx/blog.lathercraft.net/access.log main; error_log /var/log/nginx/blog.lathercraft.net/error.log warn; if (!-e $request_filename) { rewrite ^/(.+)# /index.php?q=$1 last; break; } try_files $uri $uri/ /index.php?q=$uri&$args; # php-fpm location ~\.php$ { root /var/www/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ { root /var/www/wordpress; access_log off; expires 30d; } }
で、ログファイル用のディレクトリを作ったら Nginx をリスタート。
[takatoh@tk2-254-36564 conf.d]$ sudo service nginx restart Stopping nginx: [ OK ] Starting nginx: [ OK ]
名前解決のためにゾーン編集
さくらのゾーン編集のページで、blog2.lathercraft.net を登録する。
確認
さて、これで OK のはず。ブラウザで確認してみよう。
OK、大丈夫のようだ。
[追記]
しばらく様子を見ていたけど、大丈夫のようなので、blog2.lathercraft.net ではなく blog.lahtercraft.net でアクセスできるように変更した。
これで VPS プラン乗り変え計画は全て完了した。
さくらのVPSプラン乗り換え計画(13)
PHP をインストールする。
[takatoh@tk2-254-36564 ~]$ sudo yum install php-cli php-mysql php-common php php-cgi php-fpm php-dg php-mbstring
「パッケージ php-dg は利用できません。」て出たけど、php-dg って確か画像処理のライブラリだよな。たぶん画像使わないからいいか。
インストールの確認。
[takatoh@tk2-254-36564 ~]$ php -v PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
設定ファイルを編集。
[takatoh@tk2-254-36564 ~]$ sudo cp /etc/php.ini /etc/php.ini.orig [takatoh@tk2-254-36564 ~]$ sudo vi /etc/php.ini
エラーログの場所を変更。
error_log = /var/log/php_errors.log
日本語の設定。
mbstring.language = Japanese (中略) mbstring.internal_encoding = UTF-8
http_input。
mbstring.http_input = auto
detect_order。
mbstring.detect_order = auto
expose_php を Off に。
expose_php = Off
最後にタイムゾーン。
date.timezone = Asia/Tokyo
php-fpm の設定。
設定ファイルは /etc/php-fpm.d/www.conf。
使用するポート。デフォルトのまま。
listen = 127.0.0.1:9000
許可するクライアントの IP アドレス。これも localhost だけなのでデフォルト。
listen.allowed_clients = 127.0.0.1
php-fpm サービスの実行ユーザとグループ。nginx としたので、あとで作る。
; RPM: apache Choosed to be able to access some dir as httpd user = nginx ; RPM: Keep a group allowed to write in log dir. group = nginx
php-fpm のプロセス数を定量にする。
pm = static
最大子プロセス数の設定。
pm.max_children = 5
php-fpm が受け付ける最大要求数。これを超えると子プロセスが再起動する。
pm.max_requests = 500
これで編集は終了。
実行ユーザを nginx としたので作る。
[takatoh@tk2-254-36564 ~]$ sudo useradd nginx [sudo] password for takatoh: useradd: ユーザ 'nginx' は既に存在します
あれ、あった。
じゃあ、php-fpm を起動。ついでに自動起動するように設定。
[takatoh@tk2-254-36564 ~]$ sudo /etc/init.d/php-fpm start php-fpm を起動中: [ OK ] [takatoh@tk2-254-36564 ~]$ sudo chkconfig php-fpm on [takatoh@tk2-254-36564 ~]$ sudo chkconfig --list php-fpm php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
よし、最後にテストしてみよう。Nginx のデフォルトのデータ置き場が /usr/share/nginx/html になってるので、そこに phpinfo.php ファイルを置く。
これでブラウザでアクセスしてみると……あれ?ダメだ。
そうか。Nginx に PHP 用の設定をしてないからか。デフォルトの設定ファイルに追記。
location ~\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
これでどうだ!
OK。ちゃんと表示された。
[追記]
インストールできなかった php-dg、dg じゃなくて gd だった。php-gd。
ま、どっちにしろいいか。
[更に追記]
とりあえず、php-gd もインストールしておいた。
さくらのVPSプラン乗り換え計画(12)
Rails アプリが無事動くようになったので、旧プランで動いていたアプリを止めた。
で、新プランのアプリに www.lathercraft.net でアクセスできるように設定する。
ひとつは、Nginx の設定ファイル名を変更して再起動。
もうひとつは、さくらインターネットのゾーン編集をして、www.lathercraft.net が新サーバを指すように変更。
これでいいはずだけど、ブラウザでアクセスしてみると、アプリが動いていない。どうやらまだ名前解決が旧い方を指してるみたいだ。これは時間が経てば解決するはずなので、様子を見ることにする。
さくらのVPSプラン乗り換え計画(11)
Rails アプリを unicorn で動かす。
unicornのインストールと設定
Gemfile に unicorn を追加。
gem 'unicorn'
インストール。
[root@tk2-254-36564 lathercraft]# bundle install --path vendor/bundle
unicorn の設定ファイルはつぎのようにした。
worker_processes 2 working_directory "/var/www/lathercraft" listen "/var/run/unicorn/unicorn_lathercraft.sock" pid "/var/run/unicorn/unicorn_lathercraft.pid" preload_app true timeout 1200
/var/run/unicorn ディレクトリを作成。
[root@tk2-254-36564 lathercraft]# mkdir /var/run/unicorn
Nginxの設定
upstream unicorn-lathercraft { server unix:/var/run/unicorn/unicorn_lathercraft.sock; } server { # port listen 80; # server name server_name www2.lathercraft.net; # document root root /var/www/lathercraft/public; # index #index index.php index.html index.htm; # log files access_log /var/log/nginx/www.lathercraft.net/access.log main; error_log /var/log/nginx/www.lathercraft.net/error.log warn; keepalive_timeout 6000; proxy_connect_timeout 6000; proxy_read_timeout 6000; proxy_send_timeout 6000; client_max_body_size 8192M; location /kel-mirrors { root /var/www/lathercraft/recent/; rewrite '^/kel-mirrors(.*)$' $1; break; } location / { root /var/www/lathercraft; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn-lathercraft; } }
ログファイル用のディレクトリを作成。
[root@tk2-254-36564 lathercraft]# mkdir /var/log/nginx/www.lathercraft.net
Nginxの再起動とunicornの起動
Nginx を再起動。
[root@tk2-254-36564 lathercraft]# service nginx restart Stopping nginx: [ OK ] Starting nginx: [ OK ]
unicorn を起動。
[root@tk2-254-36564 lathercraft]# export SECRET_KEY_BASE=bundle exec rails secret [root@tk2-254-36564 lathercraft]# bundle exec unicorn_rails -c unicorn.rb -E production I, [2017-05-05T11:58:43.619697 #13435] INFO -- : Refreshing Gem list DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in at /var/www/lathercraft/config/environments/production.rb:23) I, [2017-05-05T11:58:46.475292 #13435] INFO -- : listening on addr=/var/run/unicorn/unicorn_lathercraft.sock fd=10 I, [2017-05-05T11:58:46.475781 #13435] INFO -- : worker=0 spawning... I, [2017-05-05T11:58:46.479485 #13435] INFO -- : worker=1 spawning... I, [2017-05-05T11:58:46.481100 #13438] INFO -- : worker=0 spawned pid=13438 I, [2017-05-05T11:58:46.481436 #13435] INFO -- : master process ready I, [2017-05-05T11:58:46.481630 #13438] INFO -- : worker=0 ready I, [2017-05-05T11:58:46.482935 #13441] INFO -- : worker=1 spawned pid=13441 I, [2017-05-05T11:58:46.483183 #13441] INFO -- : worker=1 ready
さて、これでいいはず。
名前解決
ちゃんと動いているはずだけど、確認するには www2.lathercraft.net の名前解決化できないといけない。これはさくらインターネットのゾーン編集をする。
……結果、無事動いていることを確認。
unicornの自動起動
最後に、OS起動時に unicorn が自動起動するようにしておく。/etc/init.d/unicorn_lathercraft をつぎのようにした。
#!/bin/bash # # unicorn_lathercraft Startup script for unicorn. # # chkconfig: - 85 15 # description: lathercraft on unicorn start/stop script. # set -e set -u export PATH=/usr/local/rvm/rubies/ruby-2.3.3/bin:/usr/local/rvm/gems/ruby-2.3.3/bin:$PATH export RUBYLIB=/usr/local/rvm/gems/ruby-2.3.3:/usr/local/rvm/gems/ruby-2.3.3@global export GEM_HOME=/usr/local/rvm/gems/ruby-2.3.3:/usr/local/rvm/gems/ruby-2.3.3@global export GEM_PATH=/usr/local/rvm/gems/ruby-2.3.3:/usr/local/rvm/gems/ruby-2.3.3@global #echo `ruby -v` #echo `which ruby` APP_NAME=lathercraft APP_ROOT="/var/www/$APP_NAME" CNF="$APP_ROOT/unicorn.rb" PID="/var/run/unicorn/unicorn_lathercraft.pid" ENV=production UNICORN_OPTS="-c $CNF -E $ENV -D" old_pid="$PID.oldbin" #export SECRET_KEY_BASE=`cd /var/www/lathercraft; bundle exec rake secret` cd $APP_ROOT || exit 1 sig () { test -s "$PID" && kill -$1 `cat $PID` } oldsig () { test -s $old_pid && kill -$1 `cat $old_pid` } case ${1-help} in start) sig 0 && echo >&2 "Already running" && exit 0 cd $APP_ROOT export SECRET_KEY_BASE=`bundle exec rake secret` bundle exec unicorn_rails $UNICORN_OPTS ;; stop) sig QUIT && exit 0 echo >&2 "Not running" ;; force-stop) sig TERM && exit 0 echo >&2 "Not running" ;; restart|reload) sig HUP && echo reloaded OK && exit 0 echo >&2 "Couldn't reload, starting instead" unicorn_rails $UNICORN_OPTS ;; upgrade) sig USR2 && exit 0 echo >&2 "Couldn't upgrade, starting instead" unicorn_rails $UNICORN_OPTS ;; rotate) sig USR1 && echo rotated logs OK && exit 0 echo >&2 "Couldn't rotate logs" && exit 1 ;; *) echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>" exit 1 ;; esac
これでいいはず。スタートしてみよう。
[root@tk2-254-36564 init.d]# chmod 755 unicorn_lathercraft [root@tk2-254-36564 init.d]# service unicorn_lathercraft start
OK。
自動起動するように設定。
[root@tk2-254-36564 init.d]# chkconfig unicorn_lathercraft on [root@tk2-254-36564 init.d]# chkconfig --list unicorn_lathercraft unicorn_lathercraft 0:off 1:off 2:on 3:on 4:on 5:on 6:off
これで完了。
さくらのVPSプラン乗り換え計画(10)
新しいプランのサーバで Rails アプリが一応動くようになったので、旧プランのサーバからデータを移行する。
まずは mysqldump
コマンドで旧プランのデータベースを取り出す。
[takatoh@www2465uo ~]$ mysqldump -u lathercraft -p lathercraft_production > lcp-20170505.sql [takatoh@www2465uo ~]$ tar czf lcp-20170505.sql.tgz lcp-20170505.sql
ファイルをローカルにダウンロード。
takatoh@envelopes $ scp -P xxxxx [email protected]:lcp-20170505.sql.tgz . lcp-20170505.sql.tgz 100% 10MB 10.1MB/s 00:01
ダウンロードしたファイルを新プランのサーバにアップロード。
takatoh@envelopes $ scp -P 60000 lcp-20170505.sql.tgz [email protected]: lcp-20170505.sql.tgz 100% 10MB 10.1MB/s 00:01
新プランのサーバにログインして、.tgz ファイルを展開。
takatoh@envelopes $ ssh -p 60000 [email protected] Last login: Fri May 5 11:06:46 2017 from fntsitm001026.sitm.fnt.ngn.ppp.infoweb.ne.jp SAKURA Internet [Virtual Private Server SERVICE] [takatoh@tk2-254-36564 ~]$ ls lcp-20170505.sql.tgz [takatoh@tk2-254-36564 ~]$ tar xzf lcp-20170505.sql.tgz [takatoh@tk2-254-36564 ~]$ ls lcp-20170505.sql lcp-20170505.sql.tgz
データベースにリストアする。
[takatoh@tk2-254-36564 ~]$ mysql -u lathercraft -p lathercraft_production < lcp-20170505.sql Enter password:
アプリを立ち上げて確認。
[root@tk2-254-36564 lathercraft]# export SECRET_KEY_BASE=bundle exec rake secret [root@tk2-254-36564 lathercraft]# bundle exec rails s -e production -b 0.0.0.0 => Booting WEBrick => Rails 4.2.8 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block inat /var/lathercraft/config/environments/production.rb:23) [2017-05-05 11:18:51] INFO WEBrick 1.3.1 [2017-05-05 11:18:51] INFO ruby 2.3.3 (2016-11-21) [x86_64-linux] [2017-05-05 11:18:51] INFO WEBrick::HTTPServer#start: pid=12500 port=3000
ブラウザでも確認出来てOK。
ところでうえで気がついたんだけど、アプリを /var/www/lathercraft 以下に置くつもりが /var/lathercraft 以下においてしまっている。なので移動する。
[root@tk2-254-36564 var]# cp -r -a lathercraft www/lathercraft [root@tk2-254-36564 var]# cd www/lathercraft [root@tk2-254-36564 lathercraft]# ls Gemfile README.rdoc app config db log test vendor Gemfile.lock Rakefile bin config.ru lib public tmp
再度アプリを立ち上げて確認。
[root@tk2-254-36564 lathercraft]# bundle exec rails s -e production -b 0.0.0.0
OK。
さくらのVPSプラン乗り換え計画(9)
昨日、MySQL と Ruby のインストールが完了したので、今日は Rails アプリを動作させるところまでが目標。と言っても、現状(旧プランの VPS で)動いているアプリを真似ればいいはず。
development でテスト
いきなり本番でやるのではなくまずはテスト。
/var/www に移動して BitBucket からクローン。
[takatoh@tk2-254-36564 ~]$ cd /var [takatoh@tk2-254-36564 var]$ sudo mkdir www [takatoh@tk2-254-36564 var]$ sudo -s [root@tk2-254-36564 var]# git clone https://[email protected]/takatoh/lathercraft.git
ライブラリのインストール。
[root@tk2-254-36564 lathercraft]# bundle install --path vendor/bundle
設定ファイルを編集。
[root@tk2-254-36564 lathercraft]# cp config/secrets.yml.example config/secrets.yml [root@tk2-254-36564 lathercraft]# cp config/site_config.yml.example config/site_config.yml [root@tk2-254-36564 lathercraft]# vi config/site_config.yml
データベースのマイグレーション。
[root@tk2-254-36564 lathercraft]# bundle exec rake db:migrate
とりあえずこれでいいはず。iptables でポート 3000 番を開放して、アプリを立ち上げてみる。
[root@tk2-254-36564 lathercraft]# bundle exec rails s -b 0.0.0.0 => Booting WEBrick => Rails 4.2.8 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2017-05-05 09:53:11] INFO WEBrick 1.3.1 [2017-05-05 09:53:11] INFO ruby 2.3.3 (2016-11-21) [x86_64-linux] [2017-05-05 09:53:11] INFO WEBrick::HTTPServer#start: pid=10211 port=3000
OK。うまく動いた。
データベースの下準備
本番では、データベースに Sqlite3 じゃなく MySQL を使うので、データベースユーザを作っておく。
[root@tk2-254-36564 lathercraft]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE USER 'lathercraft'@'localhost' IDENTIFIED BY 'xxxxxxxx'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
設定ファイルの編集とデータベースのマイグレーション
本番用に設定ファイルを編集。
[root@tk2-254-36564 lathercraft]# vi config/site_config.yml [root@tk2-254-36564 lathercraft]# vi config/database.yml
config/database.yml はこうした。
(前略) production: adapter: mysql2 encoding: utf8 pool: 5 database: lathercraft_production username: lathercraft password: xxxxxxxx host: localhost
MySQL 用のライブラリがインストールされていないのでインストール。
[root@tk2-254-36564 lathercraft]# gem install mysql2 Fetching: mysql2-0.4.6.gem (100%) Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. current directory: /usr/local/rvm/gems/ruby-2.3.3/gems/mysql2-0.4.6/ext/mysql2 /usr/local/rvm/rubies/ruby-2.3.3/bin/ruby -r ./siteconf20170505-10249-1r6ezbc.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes checking for rb_big_cmp()... yes ----- Using mysql_config at /usr/bin/mysql_config ----- checking for mysql.h... no checking for mysql/mysql.h... no ----- mysql.h is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again. ----- *** 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=/usr/local/rvm/rubies/ruby-2.3.3/bin/$(RUBY_BASE_NAME) --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config To see why this extension failed to compile, please check the mkmf.log which can be found here: /usr/local/rvm/gems/ruby-2.3.3/extensions/x86_64-linux/2.3.0/mysql2-0.4.6/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.3/gems/mysql2-0.4.6 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.3.3/extensions/x86_64-linux/2.3.0/mysql2-0.4.6/gem_make.out
あれ、エラーだ。yum install mysql-devel
しろってか。
[root@tk2-254-36564 lathercraft]# yum install mysql-devel
もう一度。
[root@tk2-254-36564 lathercraft]# gem install mysql2 Building native extensions. This could take a while... Successfully installed mysql2-0.4.6 Parsing documentation for mysql2-0.4.6 Installing ri documentation for mysql2-0.4.6 Done installing documentation for mysql2 after 1 seconds 1 gem installed
OK。
じゃ、データベースの作成とマイグレーション。
[root@tk2-254-36564 lathercraft]# bundle exec rake db:create RAILS_ENV=production Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_handling.rb:50:in `establish_connection' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/mysql_database_tasks.rb:8:in `establish_connection' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/mysql_database_tasks.rb:15:in `create' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:93:in `create' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:106:in `create_current' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:17:in `block (2 levels) in ' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `' /var/lathercraft/vendor/bundle/ruby/2.3.0/bin/rake:23:in `load' /var/lathercraft/vendor/bundle/ruby/2.3.0/bin/rake:23:in `' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/exe/bundle:32:in `block in ' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/exe/bundle:24:in `' /usr/local/rvm/gems/ruby-2.3.3/bin/bundle:23:in `load' /usr/local/rvm/gems/ruby-2.3.3/bin/bundle:23:in `
[root@tk2-254-36564 lathercraft]# vi Gemfile [root@tk2-254-36564 lathercraft]# bundle install --path vendor/bundle
これでどうだ。
[root@tk2-254-36564 lathercraft]# bundle exec rake db:create RAILS_ENV=production Mysql2::Error: Access denied for user 'lathercraft'@'localhost' to database 'lathercraft_production': CREATE DATABASE `lathercraft_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci` /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.6/lib/mysql2/client.rb:120:in `_query' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.6/lib/mysql2/client.rb:120:in `block in query' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.6/lib/mysql2/client.rb:119:in `handle_interrupt' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.6/lib/mysql2/client.rb:119:in `query' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `block in execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:484:in `block in log' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:478:in `log' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:309:in `execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:225:in `execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:377:in `create_database' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/mysql_database_tasks.rb:16:in `create' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:93:in `create' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:276:in `block in each_current_configuration' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:275:in `each_current_configuration' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/tasks/database_tasks.rb:106:in `create_current' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/railties/databases.rake:17:in `block (2 levels) in ' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain' /usr/local/rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run' /var/lathercraft/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `' /var/lathercraft/vendor/bundle/ruby/2.3.0/bin/rake:23:in `load' /var/lathercraft/vendor/bundle/ruby/2.3.0/bin/rake:23:in `' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/exe/bundle:32:in `block in ' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors' /usr/local/rvm/gems/ruby-2.3.3/gems/bundler-1.14.6/exe/bundle:24:in `' /usr/local/rvm/gems/ruby-2.3.3/bin/bundle:23:in `load' /usr/local/rvm/gems/ruby-2.3.3/bin/bundle:23:in `
[root@tk2-254-36564 lathercraft]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 21 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE lathercraft_production; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON lathercraft_production.* To 'lathercraaft'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
ついでに空のデータベースもつくちゃった。
ではマイグレーション。
[root@tk2-254-36564 lathercraft]# export SECRET_KEY_BASE=bundle exec rake secret [root@tk2-254-36564 lathercraft]# bundle exec rake db:migrate RAILS_ENV=production DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in at /var/lathercraft/config/environments/production.rb:23) == 20140708134805 CreateBrands: migrating ===================================== -- create_table(:brands) -> 0.6798s -- add_index(:brands, :name, {:unique=>true}) -> 0.0727s -- add_index(:brands, :slug, {:unique=>true}) -> 0.0407s == 20140708134805 CreateBrands: migrated (0.7937s) ============================ == 20140708135345 CreateProducts: migrating =================================== -- create_table(:products) -> 0.0093s -- add_index(:products, [:brand_id, :slug], {:unique=>true}) -> 0.8482s == 20140708135345 CreateProducts: migrated (0.8579s) ========================== == 20140708140110 CreateItems: migrating ====================================== -- create_table(:items) -> 0.0908s -- add_index(:items, :md5, {:unique=>true}) -> 0.3057s == 20140708140110 CreateItems: migrated (0.3968s) ============================= == 20140708215016 DeviseCreateUsers: migrating ================================ -- create_table(:users) -> 0.0661s -- add_index(:users, :email, {:unique=>true}) -> 0.5320s -- add_index(:users, :reset_password_token, {:unique=>true}) -> 0.2549s -- add_index(:users, :confirmation_token, {:unique=>true}) -> 0.1549s == 20140708215016 DeviseCreateUsers: migrated (1.0086s) ======================= == 20140719083223 CreateCategories: migrating ================================= -- create_table(:categories) -> 0.1566s == 20140719083223 CreateCategories: migrated (0.1568s) ======================== == 20140719085230 AddCategoryIdToItem: migrating ============================== -- add_column(:items, :category_id, :integer) -> 0.5393s == 20140719085230 AddCategoryIdToItem: migrated (0.5394s) ===================== == 20140720065147 AddAdminToUsers: migrating ================================== -- add_column(:users, :admin, :boolean, {:null=>false, :default=>false}) -> 1.0957s == 20140720065147 AddAdminToUsers: migrated (1.0958s) ========================= == 20140720134222 CreateStorages: migrating =================================== -- create_table(:storages) -> 0.3241s == 20140720134222 CreateStorages: migrated (0.3243s) ========================== == 20140721073254 CreateDownloads: migrating ================================== -- create_table(:downloads) -> 0.1023s == 20140721073254 CreateDownloads: migrated (0.1025s) ========================= == 20140721080127 CreateStoredItems: migrating ================================ -- create_table(:stored_items) -> 0.1760s == 20140721080127 CreateStoredItems: migrated (0.1762s) ======================= == 20140801123109 CreateRemovedItems: migrating =============================== -- create_table(:removed_items) -> 0.2218s == 20140801123109 CreateRemovedItems: migrated (0.2219s) ====================== == 20140801132346 AddBrandToRemovedItems: migrating =========================== -- add_column(:removed_items, :brand, :string) -> 0.5079s == 20140801132346 AddBrandToRemovedItems: migrated (0.5081s) ================== == 20140802001131 AddNameToUsers: migrating =================================== -- add_column(:users, :name, :string) -> 0.1279s -- add_index(:users, :name, {:unique=>true}) -> 0.4112s == 20140802001131 AddNameToUsers: migrated (0.5393s) ========================== == 20140802070045 CreateContacts: migrating =================================== -- create_table(:contacts) -> 0.0461s == 20140802070045 CreateContacts: migrated (0.0462s) ========================== == 20140808134556 AddOnHoldToItems: migrating ================================= -- add_column(:items, :on_hold, :boolean) -> 0.2378s == 20140808134556 AddOnHoldToItems: migrated (0.2380s) ======================== == 20141029120011 AddCopyrightToProducts: migrating =========================== -- add_column(:products, :copyright, :string) -> 0.1440s == 20141029120011 AddCopyrightToProducts: migrated (0.1441s) ================== == 20141030114708 AddR18ToProducts: migrating ================================= -- add_column(:products, :r18, :boolean) -> 0.1771s == 20141030114708 AddR18ToProducts: migrated (0.1772s) ======================== == 20141106130350 CreateAdditionalLinks: migrating ============================ -- create_table(:additional_links) -> 0.1317s == 20141106130350 CreateAdditionalLinks: migrated (0.1318s) =================== == 20141213055526 AddRemoteAddrToDownloads: migrating ========================= -- add_column(:downloads, :remote_addr, :string) -> 0.0770s == 20141213055526 AddRemoteAddrToDownloads: migrated (0.0772s) ================ == 20151022105014 ChangeColumnOfItems: migrating ============================== -- change_column(:items, :file_size, :integer, {:limit=>8}) -> 0.2759s == 20151022105014 ChangeColumnOfItems: migrated (0.2761s) ===================== == 20160601172945 AddReferrerToDownloads: migrating =========================== -- add_column(:downloads, :referrer, :string) -> 0.1129s == 20160601172945 AddReferrerToDownloads: migrated (0.1130s) ================== == 20160603235736 AddDownloadsToRemovedItems: migrating ======================= -- add_column(:removed_items, :downloads, :integer) -> 0.0603s == 20160603235736 AddDownloadsToRemovedItems: migrated (0.0604s) ==============
よし。
確認
アプリを production 環境で立ち上げてみよう。
[root@tk2-254-36564 lathercraft]# bundle exec rails s -e production -b 0.0.0.0 => Booting WEBrick => Rails 4.2.8 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in at /var/lathercraft/config/environments/production.rb:23) [2017-05-05 10:34:34] INFO WEBrick 1.3.1 [2017-05-05 10:34:34] INFO ruby 2.3.3 (2016-11-21) [x86_64-linux] [2017-05-05 10:34:34] INFO WEBrick::HTTPServer#start: pid=12017 port=3000
OK。ブラウザからも確認できた。
警告が出てるのはアセット関連だな。ついでに直しておこうか。
[root@tk2-254-36564 lathercraft]# cd config/environments [root@tk2-254-36564 environments]# vi production.rb
production.rb はつぎの行を修正した(true に変更)。
config.serve_static_assets = true
アセットのプリコンパイル。
[root@tk2-254-36564 environments]# bundle exec rake assets:precompile (in /var/lathercraft) I, [2017-05-05T10:45:12.773119 #12052] INFO -- : Writing /var/lathercraft/public/assets/application-9d56a9000f8aea926db88f2516d6dbf4.js I, [2017-05-05T10:45:12.852083 #12052] INFO -- : Writing /var/lathercraft/public/assets/application-f83f6d0d6aec02ba6b82a5bb6d9cf65a.css
もう一度アプリを立ち上げて確認。
[root@tk2-254-36564 environments]# bundle exec rails s -e production -b 0.0.0.0 => Booting WEBrick => Rails 4.2.8 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in at /var/lathercraft/config/environments/production.rb:23) [2017-05-05 10:46:02] INFO WEBrick 1.3.1 [2017-05-05 10:46:02] INFO ruby 2.3.3 (2016-11-21) [x86_64-linux] [2017-05-05 10:46:02] INFO WEBrick::HTTPServer#start: pid=12055 port=3000
OK。ちゃんとスタイルシートも適用されるようになった。
とりあえずここで休憩。
さくらのVPSプラン乗り換え計画(8)
Ruby と Git のインストール。
まずは Ruby。
[takatoh@tk2-254-36564 ~]$ sudo yum install ruby
[takatoh@tk2-254-36564 ~]$ ruby --version ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
うわっ、古い!
そういえば、以前にやった時は rvm を使ったんだっけ。じゃ、今回も rvm で。
[takatoh@tk2-254-36564 takatoh]$ sudo -s [sudo] password for takatoh: [root@tk2-254-36564 takatoh]# curl -L https://get.rvm.io |bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 24062 100 24062 0 0 30050 0 --:--:-- --:--:-- --:--:-- 30050 Downloading https://github.com/rvm/rvm/archive/1.29.1.tar.gz Downloading https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc gpg: 2017年02月20日 05時02分47秒 JSTにRSA鍵ID BF04FF17で施された署名 gpg: 署名を検査できません: No public key Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures). GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.1.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc'! Try to install GPG v2 and then fetch the public key: sudo gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 or if it fails: command curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import - the key can be compared with: https://rvm.io/mpapis.asc https://keybase.io/mpapis NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.
あれ、なんかエラー?
[root@tk2-254-36564 takatoh]# gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 gpg: 鍵D39DC0E3をhkpからサーバーkeys.gnupg.netに要求 gpg: /root/.gnupg/trustdb.gpg: 信用データベースができました gpg: 鍵D39DC0E3: 公開鍵“Michal Papis (RVM signing)”を読み込みました gpg: 絶対的に信用する鍵が見つかりません gpg: 処理数の合計: 1 gpg: 読込み: 1 (RSA: 1)
ダメかな?とりあえず試してみる。
[root@tk2-254-36564 takatoh]# curl -L https://get.rvm.io |bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 24062 100 24062 0 0 14385 0 0:00:01 0:00:01 --:--:-- 10.5M Downloading https://github.com/rvm/rvm/archive/1.29.1.tar.gz Downloading https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc gpg: 2017年02月20日 05時02分47秒 JSTにRSA鍵ID BF04FF17で施された署名 gpg: “Michal Papis (RVM signing)”からの正しい署名 gpg: 別名“Michal Papis ” gpg: 別名“[jpeg image of size 5015]” gpg: 警告: この鍵は信用できる署名で証明されていません! gpg: この署名が所有者のものかどうかの検証手段がありません。 主鍵の指紋: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3 副鍵の指紋: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17 GPG verified '/usr/local/rvm/archives/rvm-1.29.1.tgz' Creating group 'rvm' Installing RVM to /usr/local/rvm/ Installation of RVM in /usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to 'rvm' group, and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows. # takatoh, # # Thank you for using RVM! # We sincerely hope that RVM helps to make your life easier and more enjoyable!!! # # ~Wayne, Michal & team. In case of problems: https://rvm.io/help and https://twitter.com/rvm_io
これでどう?
[root@tk2-254-36564 takatoh]# source /etc/profile.d/rvm.sh
今度は大丈夫そう。rmv list known
で利用可能なバージョンが見られる。
[root@tk2-254-36564 takatoh]# rvm list known # MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.6] [ruby-]2.3[.3] [ruby-]2.4[.0] ruby-head # for forks use: rvm install ruby-head---url https://github.com/github/ruby.git --branch 2.2 # JRuby jruby-1.6[.8] jruby-1.7[.26] jruby[-9.1.7.0] jruby-head # Rubinius rbx-1[.4.3] rbx-2.3[.0] rbx-2.4[.1] rbx-2[.5.8] rbx[-3.71] rbx-head # Opal opal # Minimalistic ruby implementation - ISO 30170:2012 mruby-1.0.0 mruby-1.1.0 mruby-1[.2.0] mruby[-head] # Ruby Enterprise Edition ree-1.8.6 ree[-1.8.7][-2012.02] # Topaz topaz # MagLev maglev[-head] maglev-1.0.0 # Mac OS X Snow Leopard Or Newer macruby-0.10 macruby-0.11 macruby[-0.12] macruby-nightly macruby-head # IronRuby ironruby[-1.1.3] ironruby-head
2.3 をインストール。
[root@tk2-254-36564 takatoh]# rvm install 2.3 Searching for binary rubies, this might take some time. No binary rubies available for: centos/6/x86_64/ruby-2.3.3. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for centos. Installing requirements for centos. Installing required packages: libyaml-devel, readline-devel, zlib-devel, libffi-devel, openssl-devel, sqlite-devel............. Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.3.3, this may take a while depending on your cpu(s)... ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13.7M 100 13.7M 0 0 9730k 0 0:00:01 0:00:01 --:--:-- 10.9M ruby-2.3.3 - #extracting ruby-2.3.3 to /usr/local/rvm/src/ruby-2.3.3.... ruby-2.3.3 - #configuring......................................................- ruby-2.3.3 - #post-configuration.. ruby-2.3.3 - #compiling........................................................- ruby-2.3.3 - #installing............................ ruby-2.3.3 - #making binaries executable.. ruby-2.3.3 - #downloading rubygems-2.6.12 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 749k 100 749k 0 0 3501k 0 --:--:-- --:--:-- --:--:-- 7351k No checksum for downloaded archive, recording checksum in user configuration. ruby-2.3.3 - #extracting rubygems-2.6.12.... ruby-2.3.3 - #removing old rubygems......... ruby-2.3.3 - #installing rubygems-2.6.12......................... ruby-2.3.3 - #gemset created /usr/local/rvm/gems/ruby-2.3.3@global ruby-2.3.3 - #importing gemset /usr/local/rvm/gemsets/global.gems..............| ruby-2.3.3 - #generating global wrappers........ ruby-2.3.3 - #gemset created /usr/local/rvm/gems/ruby-2.3.3 ruby-2.3.3 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.3.3 - #generating default wrappers........ ruby-2.3.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.3.3 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri [root@tk2-254-36564 takatoh]# ruby --version ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
おお、なんかうまくいったみたいだ。
さて、ついでに Git もインストール…と思ったら入ってた(古そうだけど)。
[root@tk2-254-36564 takatoh]# git --version git version 1.7.1
とりあえずここまで。
[追記]
bundler が入っていなかったのでインストール。
[root@tk2-254-36564 takatoh]# gem install bundler Fetching: bundler-1.14.6.gem (100%) Successfully installed bundler-1.14.6 Parsing documentation for bundler-1.14.6 Installing ri documentation for bundler-1.14.6 Done installing documentation for bundler after 9 seconds 1 gem installed
さくらのVPSプラン乗り換え計画(7)
Nginx のインストールと設定をする。
[takatoh@tk2-254-36564 ~]$ sudo yum install nginx [sudo] password for takatoh: 読み込んだプラグイン:fastestmirror, security インストール処理の設定をしています Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * epel: ftp.riken.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> Package nginx.x86_64 0:1.10.2-1.el6 will be インストール --> 依存性の処理をしています: nginx-filesystem = 1.10.2-1.el6 のパッケージ: nginx-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: nginx-all-modules = 1.10.2-1.el6 のパッケージ: nginx-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: nginx-filesystem のパッケージ: nginx-1.10.2-1.el6.x86_64 --> トランザクションの確認を実行しています。 ---> Package nginx-all-modules.noarch 0:1.10.2-1.el6 will be インストール --> 依存性の処理をしています: nginx-mod-stream = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch --> 依存性の処理をしています: nginx-mod-mail = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch --> 依存性の処理をしています: nginx-mod-http-xslt-filter = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch --> 依存性の処理をしています: nginx-mod-http-perl = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch --> 依存性の処理をしています: nginx-mod-http-image-filter = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch --> 依存性の処理をしています: nginx-mod-http-geoip = 1.10.2-1.el6 のパッケージ: nginx-all-modules-1.10.2-1.el6.noarch ---> Package nginx-filesystem.noarch 0:1.10.2-1.el6 will be インストール --> トランザクションの確認を実行しています。 ---> Package nginx-mod-http-geoip.x86_64 0:1.10.2-1.el6 will be インストール --> 依存性の処理をしています: GeoIP のパッケージ: nginx-mod-http-geoip-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: libGeoIP.so.1()(64bit) のパッケージ: nginx-mod-http-geoip-1.10.2-1.el6.x86_64 ---> Package nginx-mod-http-image-filter.x86_64 0:1.10.2-1.el6 will be インストール --> 依存性の処理をしています: gd のパッケージ: nginx-mod-http-image-filter-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: libgd.so.2()(64bit) のパッケージ: nginx-mod-http-image-filter-1.10.2-1.el6.x86_64 ---> Package nginx-mod-http-perl.x86_64 0:1.10.2-1.el6 will be インストール ---> Package nginx-mod-http-xslt-filter.x86_64 0:1.10.2-1.el6 will be インストール --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.18)(64bit) のパッケージ: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: libxslt.so.1(LIBXML2_1.0.11)(64bit) のパッケージ: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: libxslt.so.1()(64bit) のパッケージ: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64 --> 依存性の処理をしています: libexslt.so.0()(64bit) のパッケージ: nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64 ---> Package nginx-mod-mail.x86_64 0:1.10.2-1.el6 will be インストール ---> Package nginx-mod-stream.x86_64 0:1.10.2-1.el6 will be インストール --> トランザクションの確認を実行しています。 ---> Package GeoIP.x86_64 0:1.6.5-1.el6 will be インストール --> 依存性の処理をしています: geoipupdate のパッケージ: GeoIP-1.6.5-1.el6.x86_64 --> 依存性の処理をしています: GeoIP-data のパッケージ: GeoIP-1.6.5-1.el6.x86_64 ---> Package gd.x86_64 0:2.0.35-11.el6 will be インストール --> 依存性の処理をしています: libXpm.so.4()(64bit) のパッケージ: gd-2.0.35-11.el6.x86_64 ---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be インストール --> トランザクションの確認を実行しています。 ---> Package GeoIP-GeoLite-data.noarch 0:2017.01-1.el6 will be インストール --> 依存性の処理をしています: GeoIP-GeoLite-data-extra = 2017.01-1.el6 のパッケージ: GeoIP-GeoLite-data-2017.01-1.el6.noarch ---> Package geoipupdate.x86_64 0:2.2.1-2.el6 will be インストール ---> Package libXpm.x86_64 0:3.5.10-2.el6 will be インストール --> トランザクションの確認を実行しています。 ---> Package GeoIP-GeoLite-data-extra.noarch 0:2017.01-1.el6 will be インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ パッケージ アーキテクチャ バージョン リポジトリー 容量 ================================================================================ インストールしています: nginx x86_64 1.10.2-1.el6 epel 462 k 依存性関連でのインストールをします。: GeoIP x86_64 1.6.5-1.el6 epel 113 k GeoIP-GeoLite-data noarch 2017.01-1.el6 epel 468 k GeoIP-GeoLite-data-extra noarch 2017.01-1.el6 epel 23 M gd x86_64 2.0.35-11.el6 base 142 k geoipupdate x86_64 2.2.1-2.el6 epel 28 k libXpm x86_64 3.5.10-2.el6 base 51 k libxslt x86_64 1.1.26-2.el6_3.1 base 452 k nginx-all-modules noarch 1.10.2-1.el6 epel 7.7 k nginx-filesystem noarch 1.10.2-1.el6 epel 8.5 k nginx-mod-http-geoip x86_64 1.10.2-1.el6 epel 14 k nginx-mod-http-image-filter x86_64 1.10.2-1.el6 epel 16 k nginx-mod-http-perl x86_64 1.10.2-1.el6 epel 26 k nginx-mod-http-xslt-filter x86_64 1.10.2-1.el6 epel 16 k nginx-mod-mail x86_64 1.10.2-1.el6 epel 43 k nginx-mod-stream x86_64 1.10.2-1.el6 epel 36 k トランザクションの要約 ================================================================================ インストール 16 パッケージ 総ダウンロード容量: 25 M インストール済み容量: 51 M これでいいですか? [y/N]Y パッケージをダウンロードしています: (1/16): GeoIP-1.6.5-1.el6.x86_64.rpm | 113 kB 00:00 (2/16): GeoIP-GeoLite-data-2017.01-1.el6.noarch.rpm | 468 kB 00:00 (3/16): GeoIP-GeoLite-data-extra-2017.01-1.el6.noarch.rp | 23 MB 00:02 (4/16): gd-2.0.35-11.el6.x86_64.rpm | 142 kB 00:00 (5/16): geoipupdate-2.2.1-2.el6.x86_64.rpm | 28 kB 00:00 (6/16): libXpm-3.5.10-2.el6.x86_64.rpm | 51 kB 00:00 (7/16): libxslt-1.1.26-2.el6_3.1.x86_64.rpm | 452 kB 00:00 (8/16): nginx-1.10.2-1.el6.x86_64.rpm | 462 kB 00:00 (9/16): nginx-all-modules-1.10.2-1.el6.noarch.rpm | 7.7 kB 00:00 (10/16): nginx-filesystem-1.10.2-1.el6.noarch.rpm | 8.5 kB 00:00 (11/16): nginx-mod-http-geoip-1.10.2-1.el6.x86_64.rpm | 14 kB 00:00 (12/16): nginx-mod-http-image-filter-1.10.2-1.el6.x86_64 | 16 kB 00:00 (13/16): nginx-mod-http-perl-1.10.2-1.el6.x86_64.rpm | 26 kB 00:00 (14/16): nginx-mod-http-xslt-filter-1.10.2-1.el6.x86_64. | 16 kB 00:00 (15/16): nginx-mod-mail-1.10.2-1.el6.x86_64.rpm | 43 kB 00:00 (16/16): nginx-mod-stream-1.10.2-1.el6.x86_64.rpm | 36 kB 00:00 -------------------------------------------------------------------------------- 合計 9.5 MB/s | 25 MB 00:02 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています インストールしています : GeoIP-GeoLite-data-extra-2017.01-1.el6.noar 1/16 インストールしています : GeoIP-GeoLite-data-2017.01-1.el6.noarch 2/16 インストールしています : nginx-filesystem-1.10.2-1.el6.noarch 3/16 インストールしています : libxslt-1.1.26-2.el6_3.1.x86_64 4/16 インストールしています : geoipupdate-2.2.1-2.el6.x86_64 5/16 インストールしています : GeoIP-1.6.5-1.el6.x86_64 6/16 インストールしています : libXpm-3.5.10-2.el6.x86_64 7/16 インストールしています : gd-2.0.35-11.el6.x86_64 8/16 インストールしています : nginx-mod-http-geoip-1.10.2-1.el6.x86_64 9/16 インストールしています : nginx-mod-stream-1.10.2-1.el6.x86_64 10/16 インストールしています : nginx-mod-http-perl-1.10.2-1.el6.x86_64 11/16 インストールしています : nginx-mod-http-image-filter-1.10.2-1.el6.x8 12/16 インストールしています : nginx-mod-http-xslt-filter-1.10.2-1.el6.x86 13/16 インストールしています : nginx-1.10.2-1.el6.x86_64 14/16 インストールしています : nginx-mod-mail-1.10.2-1.el6.x86_64 15/16 インストールしています : nginx-all-modules-1.10.2-1.el6.noarch 16/16 Verifying : nginx-mod-mail-1.10.2-1.el6.x86_64 1/16 Verifying : GeoIP-1.6.5-1.el6.x86_64 2/16 Verifying : nginx-mod-http-geoip-1.10.2-1.el6.x86_64 3/16 Verifying : libXpm-3.5.10-2.el6.x86_64 4/16 Verifying : nginx-mod-stream-1.10.2-1.el6.x86_64 5/16 Verifying : nginx-all-modules-1.10.2-1.el6.noarch 6/16 Verifying : GeoIP-GeoLite-data-2017.01-1.el6.noarch 7/16 Verifying : nginx-mod-http-perl-1.10.2-1.el6.x86_64 8/16 Verifying : nginx-mod-http-image-filter-1.10.2-1.el6.x8 9/16 Verifying : nginx-1.10.2-1.el6.x86_64 10/16 Verifying : geoipupdate-2.2.1-2.el6.x86_64 11/16 Verifying : GeoIP-GeoLite-data-extra-2017.01-1.el6.noar 12/16 Verifying : libxslt-1.1.26-2.el6_3.1.x86_64 13/16 Verifying : nginx-filesystem-1.10.2-1.el6.noarch 14/16 Verifying : gd-2.0.35-11.el6.x86_64 15/16 Verifying : nginx-mod-http-xslt-filter-1.10.2-1.el6.x86 16/16 インストール: nginx.x86_64 0:1.10.2-1.el6 依存性関連をインストールしました: GeoIP.x86_64 0:1.6.5-1.el6 GeoIP-GeoLite-data.noarch 0:2017.01-1.el6 GeoIP-GeoLite-data-extra.noarch 0:2017.01-1.el6 gd.x86_64 0:2.0.35-11.el6 geoipupdate.x86_64 0:2.2.1-2.el6 libXpm.x86_64 0:3.5.10-2.el6 libxslt.x86_64 0:1.1.26-2.el6_3.1 nginx-all-modules.noarch 0:1.10.2-1.el6 nginx-filesystem.noarch 0:1.10.2-1.el6 nginx-mod-http-geoip.x86_64 0:1.10.2-1.el6 nginx-mod-http-image-filter.x86_64 0:1.10.2-1.el6 nginx-mod-http-perl.x86_64 0:1.10.2-1.el6 nginx-mod-http-xslt-filter.x86_64 0:1.10.2-1.el6 nginx-mod-mail.x86_64 0:1.10.2-1.el6 nginx-mod-stream.x86_64 0:1.10.2-1.el6 完了しました!
終わったら起動。ついでに、サーバ起動時に自動起動するように設定。
[takatoh@tk2-254-36564 ~]$ sudo service nginx start Starting nginx: [ OK ] [takatoh@tk2-254-36564 ~]$ sudo chkconfig nginx on [takatoh@tk2-254-36564 ~]$ sudo chkconfig --list nginx nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
これでブラウザでアクセスできれば OK ……って、できないな。あ、ファイアウォールか。
/etc/sysconfig/iptables の ssh の次に1行追加。
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
[takatoh@tk2-254-36564 ~]$ sudo service iptables restart
今度はブラウザからもアクセスできた。
さくらのVPSプラン乗り換え計画(6)
MySQL をインストール。
[takatoh@tk2-254-36564 ~]$ sudo yum install mysql-server [sudo] password for takatoh: 読み込んだプラグイン:fastestmirror, security インストール処理の設定をしています Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * epel: ftp.riken.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be インストール --> 依存性の処理をしています: mysql = 5.1.73-8.el6_8 のパッケージ: mysql-server-5.1.73-8.el6_8.x86_64 --> 依存性の処理をしています: perl-DBI のパッケージ: mysql-server-5.1.73-8.el6_8.x86_64 --> 依存性の処理をしています: perl-DBD-MySQL のパッケージ: mysql-server-5.1.73-8.el6_8.x86_64 --> 依存性の処理をしています: perl(DBI) のパッケージ: mysql-server-5.1.73-8.el6_8.x86_64 --> トランザクションの確認を実行しています。 ---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be インストール ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be インストール ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ パッケージ アーキテクチャ バージョン リポジトリー 容量 ================================================================================ インストールしています: mysql-server x86_64 5.1.73-8.el6_8 base 8.6 M 依存性関連でのインストールをします。: mysql x86_64 5.1.73-8.el6_8 base 895 k perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k perl-DBI x86_64 1.609-4.el6 base 705 k トランザクションの要約 ================================================================================ インストール 4 パッケージ 総ダウンロード容量: 10 M インストール済み容量: 29 M これでいいですか? [y/N]Y パッケージをダウンロードしています: (1/4): mysql-5.1.73-8.el6_8.x86_64.rpm | 895 kB 00:00 (2/4): mysql-server-5.1.73-8.el6_8.x86_64.rpm | 8.6 MB 00:00 (3/4): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00 (4/4): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:00 -------------------------------------------------------------------------------- 合計 8.1 MB/s | 10 MB 00:01 rpm_check_debug を実行しています トランザクションのテストを実行しています トランザクションのテストを成功しました トランザクションを実行しています インストールしています : perl-DBI-1.609-4.el6.x86_64 1/4 インストールしています : perl-DBD-MySQL-4.013-3.el6.x86_64 2/4 インストールしています : mysql-5.1.73-8.el6_8.x86_64 3/4 インストールしています : mysql-server-5.1.73-8.el6_8.x86_64 4/4 Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/4 Verifying : mysql-server-5.1.73-8.el6_8.x86_64 2/4 Verifying : mysql-5.1.73-8.el6_8.x86_64 3/4 Verifying : perl-DBI-1.609-4.el6.x86_64 4/4 インストール: mysql-server.x86_64 0:5.1.73-8.el6_8 依存性関連をインストールしました: mysql.x86_64 0:5.1.73-8.el6_8 perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 完了しました!
設定ファイルは /etc/my.cnf。バックアップをとってから編集。
[takatoh@tk2-254-36564 ~]$ sudo cp /etc/my.cnf /etc/my.cnf.orig [takatoh@tk2-254-36564 ~]$ sudo vi /etc/my.cnf
つぎのようにした。色を付けたところが追加したところ。
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 character_set_server=utf8 default-storage-engine=InnoDB innodb_file_per_table [mysql] default-character-set=utf8 [mysqldump] default-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
これで起動。
[takatoh@tk2-254-36564 ~]$ sudo service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h tk2-254-36564.vs.sakura.ne.jp password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ]
おお、大丈夫みたいだ。
mysql
コマンドで確かめてみる。
[takatoh@tk2-254-36564 ~]$ mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | +--------------------+ 2 rows in set (0.00 sec)
mysql_secure_installation
を実行する。
[takatoh@tk2-254-36564 ~]$ sudo mysql_secure_installation
途中で root のパスワードを訊かれるので入力する。その他はエンターを叩けば OK。
試してみよう。
[takatoh@tk2-254-36564 ~]$ mysql ERROR 1045 (28000): Access denied for user 'takatoh'@'localhost' (using password: NO) [takatoh@tk2-254-36564 ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
ユーザーとパスワードを入力しなければならなくなった。これでよし。