nginx centos6.xで無料のSSL通信をする方法

Certbot クライアントの必要なパッケージの追加

sudo yum install epel-release

Certbot クライアントをダウンロード・インストールする

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto

Certbot のインストール


一通り必要なPackageのインストール

私の環境では下記のPackageのインストールが必要となり
yesの入力

============================================================================================================================================================================================================================================================================================================================
 Package                                                                           Arch                                                                 Version                                                                                 Repository                                                             Size
============================================================================================================================================================================================================================================================================================================================
Installing:
 libffi-devel                                                                      x86_64                                                               3.0.5-3.2.el6                                                                           base                                                                   18 k
 mod_ssl                                                                           x86_64                                                               1:2.2.15-60.el6.centos.6                                                                updates                                                                99 k
 openssl-devel                                                                     x86_64                                                               1.0.1e-57.el6                                                                           base                                                                  1.2 M
 python34                                                                          x86_64                                                               3.4.5-4.el6                                                                             epel                                                                   50 k
 python34-devel                                                                    x86_64                                                               3.4.5-4.el6                                                                             epel                                                                  186 k
 python34-tools                                                                    x86_64                                                               3.4.5-4.el6                                                                             epel                                                                  425 k
Updating:
 ca-certificates                                                                   noarch                                                               2017.2.14-65.0.1.el6_9                                                                  updates                                                               1.3 M
 gcc                                                                               x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                                10 M
 openssl                                                                           x86_64                                                               1.0.1e-57.el6                                                                           base                                                                  1.5 M
 redhat-rpm-config                                                                 noarch                                                               9.0.3-51.el6.centos                                                                     base                                                                   60 k
Installing for dependencies:
 keyutils-libs-devel                                                               x86_64                                                               1.4-5.el6                                                                               base                                                                   29 k
 krb5-devel                                                                        x86_64                                                               1.10.3-65.el6                                                                           base                                                                  504 k
 libcom_err-devel                                                                  x86_64                                                               1.41.12-23.el6                                                                          base                                                                   33 k
 libkadm5                                                                          x86_64                                                               1.10.3-65.el6                                                                           base                                                                  143 k
 libselinux-devel                                                                  x86_64                                                               2.0.94-7.el6                                                                            base                                                                  137 k
 libsepol-devel                                                                    x86_64                                                               2.0.41-4.el6                                                                            base                                                                   64 k
 python-rpm-macros                                                                 noarch                                                               3-11.el6                                                                                epel                                                                  5.4 k
 python-srpm-macros                                                                noarch                                                               3-11.el6                                                                                epel                                                                  4.8 k
 python3-rpm-macros                                                                noarch                                                               3-11.el6                                                                                epel                                                                  4.9 k
 python34-libs                                                                     x86_64                                                               3.4.5-4.el6                                                                             epel                                                                  8.3 M
 python34-tkinter                                                                  x86_64                                                               3.4.5-4.el6                                                                             epel                                                                  336 k
 tcl                                                                               x86_64                                                               1:8.5.7-6.el6                                                                           base                                                                  1.9 M
 tk                                                                                x86_64                                                               1:8.5.7-5.el6                                                                           base                                                                  1.4 M
 zlib-devel                                                                        x86_64                                                               1.2.3-29.el6                                                                            base                                                                   44 k
Updating for dependencies:
 cpp                                                                               x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               3.7 M
 e2fsprogs                                                                         x86_64                                                               1.41.12-23.el6                                                                          base                                                                  554 k
 e2fsprogs-libs                                                                    x86_64                                                               1.41.12-23.el6                                                                          base                                                                  121 k
 gcc-c++                                                                           x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               4.7 M
 gcc-gfortran                                                                      x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               4.7 M
 httpd                                                                             x86_64                                                               2.2.15-60.el6.centos.6                                                                  updates                                                               836 k
 httpd-tools                                                                       x86_64                                                               2.2.15-60.el6.centos.6                                                                  updates                                                                80 k
 krb5-libs                                                                         x86_64                                                               1.10.3-65.el6                                                                           base                                                                  675 k
 libcom_err                                                                        x86_64                                                               1.41.12-23.el6                                                                          base                                                                   38 k
 libgcc                                                                            x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               103 k
 libgfortran                                                                       x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               268 k
 libgomp                                                                           x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               134 k
 libselinux                                                                        x86_64                                                               2.0.94-7.el6                                                                            base                                                                  109 k
 libselinux-utils                                                                  x86_64                                                               2.0.94-7.el6                                                                            base                                                                   82 k
 libss                                                                             x86_64                                                               1.41.12-23.el6                                                                          base                                                                   42 k
 libstdc++                                                                         x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               296 k
 libstdc++-devel                                                                   x86_64                                                               4.4.7-18.el6_9.2                                                                        updates                                                               1.6 M

Transaction Summary
============================================================================================================================================================================================================================================================================================================================
Install      20 Package(s)
Upgrade      21 Package(s)

Total download size: 46 M
Is this ok [y/N]: y

Certbot のインストールの成功

『Complete!』の確認とエラー時は
ログの確認
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Installed:
  libffi-devel.x86_64 0:3.0.5-3.2.el6                 mod_ssl.x86_64 1:2.2.15-60.el6.centos.6                 openssl-devel.x86_64 0:1.0.1e-57.el6                 python34.x86_64 0:3.4.5-4.el6                 python34-devel.x86_64 0:3.4.5-4.el6                 python34-tools.x86_64 0:3.4.5-4.el6

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.4-5.el6   krb5-devel.x86_64 0:1.10.3-65.el6    libcom_err-devel.x86_64 0:1.41.12-23.el6   libkadm5.x86_64 0:1.10.3-65.el6   libselinux-devel.x86_64 0:2.0.94-7.el6   libsepol-devel.x86_64 0:2.0.41-4.el6   python-rpm-macros.noarch 0:3-11.el6   python-srpm-macros.noarch 0:3-11.el6
  python3-rpm-macros.noarch 0:3-11.el6     python34-libs.x86_64 0:3.4.5-4.el6   python34-tkinter.x86_64 0:3.4.5-4.el6      tcl.x86_64 1:8.5.7-6.el6          tk.x86_64 1:8.5.7-5.el6                  zlib-devel.x86_64 0:1.2.3-29.el6

Updated:
  ca-certificates.noarch 0:2017.2.14-65.0.1.el6_9                                        gcc.x86_64 0:4.4.7-18.el6_9.2                                        openssl.x86_64 0:1.0.1e-57.el6                                        redhat-rpm-config.noarch 0:9.0.3-51.el6.centos

Dependency Updated:
  cpp.x86_64 0:4.4.7-18.el6_9.2              e2fsprogs.x86_64 0:1.41.12-23.el6  e2fsprogs-libs.x86_64 0:1.41.12-23.el6  gcc-c++.x86_64 0:4.4.7-18.el6_9.2  gcc-gfortran.x86_64 0:4.4.7-18.el6_9.2  httpd.x86_64 0:2.2.15-60.el6.centos.6   httpd-tools.x86_64 0:2.2.15-60.el6.centos.6  krb5-libs.x86_64 0:1.10.3-65.el6
  libcom_err.x86_64 0:1.41.12-23.el6         libgcc.x86_64 0:4.4.7-18.el6_9.2   libgfortran.x86_64 0:4.4.7-18.el6_9.2   libgomp.x86_64 0:4.4.7-18.el6_9.2  libselinux.x86_64 0:2.0.94-7.el6        libselinux-utils.x86_64 0:2.0.94-7.el6  libss.x86_64 0:1.41.12-23.el6                libstdc++.x86_64 0:4.4.7-18.el6_9.2
  libstdc++-devel.x86_64 0:4.4.7-18.el6_9.2

Complete!
Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Certbot 対話式でSSL化

Webサーバの種類を選択

Nginxなので2を入力してエンター

How would you like to authenticate and install certificates?
-------------------------------------------------------------------------------
1: Apache Web Server plugin - Beta (apache)
2: Nginx Web Server plugin - Alpha (nginx)
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):2
メールアドレスの入力
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel):sample@gmail.com


注意事項の確認をして納得すれば
Aを入力してエンター

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel:A
上記のメールアドレスをメーリングリストに追加していいかの確認

Nを入力してエンター

-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o:N
SSL化するサイトを選択

sample.comをSSLかするので
1を入力してエンター

Which names would you like to activate HTTPS for?
-------------------------------------------------------------------------------
1: sample.com
2: exsample.com
3: test.com
-------------------------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):1
HTTPからのアクセスをどのように処理するか選択

HTTPSへとリダイレクトしたいので
2を入力してエンター

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):2
終了メッセージの確認
-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://sample.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=sample.com
-------------------------------------------------------------------------------

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sample.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sample.com/privkey.pem
   Your cert will expire on 2018-08-17. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

選択肢に存在しない場合の確認点

nginxのサーバネーム時にドットを先頭につける記法だと
certbot-autoにて認識しない為
一度、ドットなしの記載を行う

下記では認識してくれないので

    server_name .sample.com;

このように書き下す必要あり

    server_name sample.com www.sample.com;

全てのプログラマー必見!良書の『達人プログラマー』の新装版が発売

30代以上のIT系の仕事をしている人ならご存知の
IT系バイブル

達人プログラマー―システム開発の職人から名匠への道

達人プログラマー―システム開発の職人から名匠への道

  • 作者: アンドリューハント,デビッドトーマス,Andrew Hunt,David Thomas,村上雅章
  • 出版社/メーカー: ピアソンエデュケーション
  • 発売日: 2000/11
  • メディア: 単行本
  • 購入: 42人 クリック: 1,099回
  • この商品を含むブログ (349件) を見る

絶版から時を越えて、装い新たにオーム社から発売されました。

新装版 達人プログラマー 職人から名匠への道

新装版 達人プログラマー 職人から名匠への道

全てのプログラマーに読んでほしい良書です。

私自身も、25歳の頃
たまたま、この書籍に出会い
目から鱗が落ちる思いをしました。

ピアソン・エデュケーション版の本書が既に絶版となって
少しがっかりしていましたが
出版社が変わったことにより訳が全面的に改稿されていますが
内容は同じままです。

騙されたと思ってぜひ一度
読んでみてください。

『STINGER PLUS+』をウィジェット 機能付きの3カラム表示に改造する方法

WordPressを用いたブログでは有名な『STINGER』の最新版である
『STINGER PLUS+』をウィジェット 機能付きの3カラムに変更した方法です。

全て、WordPressの『テーマの編集』機能でできます。

左サイドバーウィジェット の追加方法

下記のコードを

register_sidebar( array(
	'id' => 'sidebar-14',
	'name' => '左サイドバーウイジェット',
	'description' => '左側のサイドバーウィジェットです。カスタム追加',
	'before_widget' => '<div class="top-wbox-u">',
	'after_widget' => '</div>',
	'before_title' => '<p style="display:none">',
	'after_title' => '</p>',
) );

function st_register_sidebars()
内に追加します。

これで下記の赤丸部分が追加されます。

f:id:m1200056:20161103033154j:plain


次に、まずはTOPページから3カラム表示にしていきます。
操作するファイルは『投稿ページ (home.php)』です。


『左サイドバーウィジェット』を表示できるように

と既存の右サイドバーを包括した

を新規に追加して
と同列に
を追加します。

ざっくりイメージは

<div id="content" class="clearfix">
    <div id="content-right"><!-- 新規追加 -->
        <div id="contentInner">
    ・・・
	</div>
	<!-- /#contentInner -->
	<?php get_sidebar(); ?>
    </div><!-- /#content-right -->
<div id="sidel"><!-- 新規追加 -->
    <aside>
        <?php if ( is_active_sidebar( 14 ) ) { ?>
            <div class="side-topad">
                <?php if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( 14 ) ) : else : ?>
                    <?php endif; ?>
                        </div>
                   <?php } ?>
    </aside>
</div><!-- /#sidel -->
   

最後にCSSで全体の調整

下記を『スタイルシート (style.css)』に追加

/*media Queries タブレットサイズ(960px以上)
----------------------------------------------------*/
@media only screen and (min-width: 960px) {

	#content-right {
 	   width: 980px !important;
	    float: right !important;
	    margin-left: 20px !important;
	}
/*-- ここまで --*/
}


下記の部分を変更

/*レイアウト スマートフォン
----------------------------------------------------*/
#wrapper {
	max-width: 1220px;   // ここを調整
	padding: 0 10px;
	margin: 0 auto;
	overflow:hidden;
}


これで、TOPページが3カラム化出来たはずです。


後は『投稿ページ (home.php)』と同様な処理を

・404 テンプレート(404.php)
・アーカイブ(archive.php)
・カテゴリーテンプレート(category.php)
・メインインデックスのテンプレート(index.php)
・検索結果(search.php)
・個別投稿(single.php)

へ行って終了。

mac book proのHDDの空きが少なくなってきたので大掃除をした

3年前に購入したmac book proの空きが少なくなってきたので この度、

ファイルの大掃除を行いました。

いらないファイルを順々に消していくのもいいのですが

ひとまず、100GBくらいの空き容量をかせぎたかったので

サイズの大きなディレクトリから処理して行くことにしました。

その手順を下記に示します。

まずは、コマンドプロンプトで 以下のコマンドを実行

>sudo du -sh /*

こうするとルートディレクトリ以下の 各ディレクトリの

使用サイズが表示されます。

ここで、

/Usersディレクトリのサイズが大きいことがわかったので

さらに下記コマンドで/Usersディレクトリ以下のサイズを確認

>sudo du -sh /Users/*

これを繰り返すことによって

大きなサイズの不要ファイルを探すのが楽になります。

開発マシンにしていると

不要なログがかなり溜まることもあるので

人によってはかなりすっきりするかも。

ただ、写真など消せない思い出のファイルや

念のためとっておきたい仕事上のファイルなどは

外付けHDDを買ってお引越し。

最近は3TBでも1万円を切るものがあって嬉しいですね。


iPhoneの新作マリオ「スーパーマリオラン」が「ソニック・ザ・ヘッジホッグ 」だった...

2016年9月7日10時(日本時間9月8日2時)からのApple新製品の発表会の
一発目で出てきた任天堂

そこで発表されたのは....

「スーパーマリオラン」

デモを見て世界中のみんなが思っただろう...

それ

「ソニック・ザ・ヘッジホッグ」

明日のアップルと任天堂の株価が心配だ...

nginxのエラーログ出力方法と確認

設定ファイルの確認

デフォルト設定時
     /etc/nginx/nginx.conf
の中を確認しerror_logが記載れているかチェック

 デフォルトでは下記のように記載されている。

 
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

上記の場合、ログファイルは /var/log/nginx/error.logに吐き出され

書き込まれるエラーレベルはwarn以上となる。

 

エラーログのレベル(上に行くほど、重要度大)

  • emerg: Emergency situations where the system is in an unusable state.

  • alert: Severe situation where action is needed promptly.

  • crit: Important problems that need to be addressed.

  • error: An Error has occurred. Something was unsuccessful.

  • warn: Something out of the ordinary happened, but not a cause for concern.

  • notice: Something normal, but worth noting has happened.

  • info: An informational message that might be nice to know.

  • debug: Debugging information that can be useful to pinpoint where a problem is occurring.

 

エラーログ[和訳]

  • emerg: システムが使用できない状態にある緊急事態。
  • alert: 早急に対応すべき事態
  • crit: 対処すべき重要な問題
  • error: 何かが失敗している。
  • warn: 正常じゃないことが起こっているけど、そんな重要じゃないよ
  • notice: いたって普通だけど、注意すべきことが起こっている
  • info: 知っておくといいかもしれない情報
  • debug: 問題が起こっている場所を知るのに有効な情報

 エラーログのレベルの動作

 下位のレベルを指定すると、上位のレベルも出力されます。

 例えば)

  errorを指定すると、その上位のcrit, alert, emergレベルのログも吐き出されます。

 

 debugログの注意

 標準ではdebugログは出力しません。

   コンパイルオプション

     --with-debug

    を指定してnginxをビルドする必要があります。