カテゴリー : 2012年 11月

[Apache] Passenger の Basic 認証設定

Apache + Passenger で Basic 認証を設定したのでメモ。

myuser というユーザのパスワードファイルを作成する。

# htpasswd -c /usr/local/apache2/.htpasswd myuser

Apache の設定ファイルを修正する。

# vim /usr/local/apache2/conf/extra/passenger.conf
<VirtualHost *:80>
    PassengerUserSwitching off
    PassengerDefaultUser app
 
    ServerName example.com
    DocumentRoot "/srv/example.com/current/public"
    ErrorLog "logs/example.com-error_log"
    CustomLog "logs/example.com-access_log" common
    <Directory /srv/example.com/current/public>
        AllowOverride all
        Options -MultiViews
        Order allow,deny
        Allow from all
    </Directory>
    <Location />
        AuthType Basic
        AuthName "Please enter your ID and Password"
        AuthUserFile /usr/local/apache2/.htpasswd
        Require user myuser
    </Location>
 
</VirtualHost>

Apache の再起動

# service httpd restart

以上です。

【参考】

@IT:Apacheでユーザー認証を行うには(Basic認証編) はてなブックマーク - @IT:Apacheでユーザー認証を行うには(Basic認証編)

blog.sowatchasayin: rails + passengerでbasic認証 はてなブックマーク - blog.sowatchasayin: rails + passengerでbasic認証

Bloggerで独自ドメインを設定する方法

友人に「Bloggerに独自ドメインを割当てたい」と相談されたので、参考になりそうなリンクをまとめてみました。

前提

・xxx.com みたいなのどうやって取得するの?
・Blogger のURLを .com にしたい

お名前.com でドメイン取得後の設定方法

Bloggerで始める 発信URLを独自ドメインで統一するプロジェクト :教えて君.net はてなブックマーク - Bloggerで始める 発信URLを独自ドメインで統一するプロジェクト :教えて君.net

Bloggerで独自ドメインを使う最初の難関 「お名前.com」にレンタルDNSレコードを設定する :教えて君.net はてなブックマーク - Bloggerで独自ドメインを使う最初の難関 「お名前.com」にレンタルDNSレコードを設定する :教えて君.net

Blogger に独自ドメインを割当てる方法

Bloggerを独自ドメインで運営する はてなブックマーク - Bloggerを独自ドメインで運営する

ブログでカスタム ドメイン名を使用するには – Blogger ヘルプ はてなブックマーク - ブログでカスタム ドメイン名を使用するには - Blogger ヘルプ

Bloggerに独自ドメインを割当てるメリット

分かりやすくまとめられていて、今すぐ設定したくなる。

Bloggerブログを独自ドメインにした3つの理由 | +PlusOneWorld はてなブックマーク - Bloggerブログを独自ドメインにした3つの理由 | +PlusOneWorld

以上、こんな感じ。

あとはFacebookメッセージで適宜、対応しつつ設定して貰う予定。

[PHP] 機種依存文字の文字コード変換(EUC-JP→UTF-8)

PHP で、EUC-JP から UTF-8 への機種依存文字の文字コード変換する方法をメモ。

mb_convert_encoding(mb_convert_encoding($value,"sjis-win","EUC-JP"),"UTF-8","sjis-win")

EUC-JP から sjis-win へ変換後、sjis-win から UTF-8 へ変換することで、機種依存文字も含めて正常に文字コード変換できるみたいです。


参考情報

PHPで、いわゆる機種依存文字の文字コード変換(EUC-JP→UTF-8)にはまる - エンジニアが作る最新ITブログ by DODA

PHP の mbstring に関するメモ

[Mac] iTunes の移行作業

Mac から Mac へ iTunes の移行作業をしました。

この記事が超参考になりました。

新しいMacにiTunesのライブラリのデータを移行させる方法 – たのしいiPhone! AppBank はてなブックマーク - 新しいMacにiTunesのライブラリのデータを移行させる方法 - たのしいiPhone! AppBank

てか、ローカルに音楽ファイル置く時代じゃないよね。

[iptables] Applying firewall rules: iptables-restore v1.4.7: no command specified Error occurred at line: 6

iptables を編集後、再起動したらエラーが発生しました。

■ エラーメッセージ

# service iptables restart
iptables: Applying firewall rules: iptables-restore v1.4.7: no command specified
Error occurred at line: 6
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
                                                           [FAILED]

■ 解決方法

何も書いてない行にスペースがないか確認する。
→スペースがある場合、削除する

以上です。


参考情報

さくらのVPSへのiptablesの設定 | 9ensanのLifeHack

[Server] CentOS6.3 on さくらのVPS の初期設定

まず、前提としてさくらのVPSにインストールされている CentOS は 64bit 版みたいです。

(最終更新日:2013/09/15)

続きを読む

[Ruby] cannot load such file — ci/reporter/rake/rspec

Ruby on Rails で Capistrano でデプロイしたら、bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile の実行で下記のエラーが発生したので、解決方法をメモ。

■ エラーメッセージ

cannot load such file -- ci/reporter/rake/rspec

ci_reporter は development, test 環境のみにインストールする gem なので、Rakefile に LoadError の例外をキャッチするコードを追記して、production 環境でも動くように対応しました。

% cat Rakefile 
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
require File.expand_path('../config/application', __FILE__)
 
begin
  require 'ci/reporter/rake/rspec'
rescue LoadError
end
 
myapp::Application.load_tasks

以上です。

[Mac] MySQL を Homebrew でインストール

Mac に MySQL を Homebrew でインストールしたので、その手順をご紹介します。(最終更新日:2017/03/25)

MySQL

続きを読む

Ruby1.9.3 を CentOS6.3 にソースコードからインストールする手順メモ

Ruby1.9.3 を CentOS6.3 にソースコードからインストールする手順をメモ。

■ yum

# yum check-update
# yum update
# yum -y install openssl-devel zlib-devel readline-devel

■ yaml のインストール

# cd /usr/src/
# wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
# tar zxvf yaml-0.1.4.tar.gz 
# cd yaml-0.1.4
# ./configure |& tee configure.log
# make |& tee make.log
# make install

■ Ruby のインストール
ダウンロード – Ruby はてなブックマーク - ダウンロード

# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz
# tar zxvf ruby-1.9.3-p286.tar.gz
# cd ruby-1.9.3-p286
# ./configure \
--prefix=/usr/local \
--enable-shared \
--disable-install-doc \
--with-opt-dir=/usr/local/lib \
|& tee configure.log
# make |& tee make.log
# make install
# ruby -v

■ Gem のアップデート

# gem -v
1.8.23
# gem update --system
# gem -v
1.8.24

以上です。

【参考】

完全にメモ。CentOS 6.2 に ruby をインストール : てるてる坊主 はてなブックマーク - 完全にメモ。CentOS 6.2 に ruby をインストール : てるてる坊主

[JavaScript] RSA 公開鍵を使った暗号化/復号化ができるライブラリ「cryptico.js」

JavaScript で RSA 公開鍵を使った暗号化/復号化ができるライブラリ「cryptico.js」が使いやすそうなのでメモ。

wwwtyro/cryptico · GitHub はてなブックマーク - wwwtyro/cryptico · GitHub

JavaScriptで RSA 公開鍵による暗号化、復号化が出来るライブラリ「cryptico.js」 | Web活メモ帳 はてなブックマーク - JavaScriptで RSA 公開鍵による暗号化、復号化が出来るライブラリ「cryptico.js」 | Web活メモ帳

以上です。