Archive for: 󈥪月 2015’

Capstrano3とRuby2.2 on Rails4.2 の設定

2015年10月18日 Posted by PURGE

Capstrano3を使用しようと試しているが、かなりハマっている。
下記は覚え書き。

rbenvでrubyのバージョンが設定されていないエラー

ERROR rbenv: rbenv_ruby is not set

rbenvのパスが検出されないエラー

ERROR rbenv: 2.2.2 is not installed or not found in ~/.rbenv/versions/2.2.2

deploy.rb

## デプロイサーバのパスを記述
set :rbenv_path, '/var/rbenv'
set :rbenv_ruby, '2.2.2'
set :application, 'Sample'
set :repo_url, 'ssh://hoge@whoocus.com/path/to/git/repo/sample.git'

サーバ上でbundleが見つからないエラー

bundle stderr: rbenv: bundle: command not found

サーバ上でインストール。

gem install bundler

JavaScript runtimeが見つからないとのエラー。

JS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.

Gemfile

gem 'execjs'
gem 'therubyracer', platforms: :ruby

Nginxのバーチャルホスト設定

2015年10月2日 Posted by PURGE

バーチャルホストの設定についての体系的な記述が見当たらなかった。
下記の設定方法が正当であるかどうかは不明であるが一つの定番例として覚え書き。

バーチャルホスト設定ファイル配置用のディレクトリ作成

これは習慣的な方法らしく、sites-availableに設定ファイル実体を配置して、sites-enabledに設定ファイルへのシンボリックリンクを張るらしい。
シンボリックリンクを削除することで、簡単にバーチャルホストのサイトを閉鎖することが可能となる。

$ mkdir /etc/nginx/sites-available
$ mkdir /etc/nginx/sites-enabled

sites-availableに設定ファイルを配置

/etc/nginx/sites-available/virtualhost.com

server {
    listen       80;
    server_name www.virtualhost.com;
    access_log  /var/log/nginx/virtualhost.com.access.log;
    location / {
        root   /var/www/html/virtualhost;
        index  index.html index.htm index.php;
    }
    location ~ \.php$ {
        root           /var/www/html/virtualhost;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/html/virtualhost$fastcgi_script_name;
        include        fastcgi_params;
    }
}
$ cd /etc/nginx/sites-enabled/
$ ln -s /etc/nginx/sites-available/virtualhost.com virtualhost.com

シンボリックリンクのあるsites-enabledに対してインクルード

/etc/nginx/nginx.conf

include /etc/nginx/sites-enabled/*;

Apache HTTP Serverに比べると、直感的にも設定ファイルがわかりやすく記述できる。

Ruby2.X.XのCentOS6へのインストール方法

2015年10月2日 Posted by PURGE

Rubyのバージョンを管理しやすいようにrbebvを使用して最新Rubyをインストールしようと思い覚え書き。

rbenvのインストール

$ mkdir /var/rbenv
$ git clone git://github.com/sstephenson/rbenv.git
$ chmod -R 777 /var/rbenv
$ cd /var/rbenv/plugins
$ git clone git://github.com/sstephenson/ruby-build.git

環境変数設定

$ vi /etc/profile.d/rbenv.sh
export RBENV_ROOT="/var/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"

必要なライブラリのインストール

$ yum install -y readline-devel

Rubyのインストール

$ rbenv install 2.X.X
Installing ruby-2.X.X...

Rubyバージョンの選択

$ rbenv global 2.X.X

Rubyバージョンの確認

$ ruby --version
ruby 2.X.X (2015-08-18 revision 51636) [x86_64-linux]

成功した。

MySQL5.6のCentOS6へのインストール方法

2015年10月2日 Posted by PURGE

リポジトリ設定

$ yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

インストール

$ yum install mysql-community-server

バージョンの確認

$ mysqld --version
mysqld  Ver 5.6.26 for Linux on x86_64 (MySQL Community Server (GPL))

自動起動設定

$ chkconfig mysqld on
$ chkconfig --list mysqld
  mysqld            0:off   1:off   2:on    3:on    4:on    5:on    6:off

サーバの起動

$ service mysqld start

サーバの停止

$ /etc/init.d/mysqld stop

Nginx1.8のCentOS6へのインストール方法

2015年10月2日 Posted by PURGE

普通にyumインストールすると、古いバージョンのNginxがインストールされてしまう。

リポジトリ設定

$ rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

インストール

$ yum install nginx

自動起動設定

$ chkconfig nginx on
$ chkconfig nginx --list
  nginx             0:off   1:off   2:on    3:on    4:on    5:on    6:off

サーバの起動

$ nginx

ブラウザで確認

スクリーンショット 2015-09-30 13.29.17.png

サーバの停止

$ nginx -s stop

簡単です。

Markdown

2015年10月2日 Posted by PURGE

h1

h2

h3

WordPressでマークダウンを使用するかどうか?のテスト投稿。
ABC abc 123 あいうえお

public staic void main(){
    println("Hello World!!");
}

太字

斜字

~~打ち消し線はサポート無し~~

私はrubyが好きです。


リンク

左寄せ 中央寄せ 右寄せ
abc abc 123