nginxのエラー“increase server_names_hash_bucket_size”の対処方法

当ページのリンクには広告が含まれています。

スポンサーリンク

nginx起動時のエラー“increase server_names_hash_bucket_size”の対処方法を説明します。

エラーの対処方法

nginxの設定ファイルにバーチャルホスト(同じIPアドレスで複数のサイトを運用)を設定し、構文チェックをすると下記のようなエラーが表示される場合があります。

# /etc/init.d/nginx configtest
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

これはバーチャルホストのドメイン名が長い時に表示されるエラーで、nginxの設定ファイル(/etc/nginx/nginx.conf)を編集すればOKです。

# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
# vi /etc/nginx/nginx.conf
server_names_hash_bucket_size 64; ← 32から64に増やします

diffコマンドで比較

適切に編集できているかを確認するためにdiffコマンドで比較します。

# diff /etc/nginx/nginx.conf.old /etc/nginx/nginx.conf
23c23
< 	server_names_hash_bucket_size 32;
---
> 	server_names_hash_bucket_size 64;

設定ファイルが適切に編集されているを確認します。上記設定でもエラーが表示される場合は、値を128に変更して下さい。

# /etc/init.d/nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginxを起動します。

# /etc/init.d/nginx start
nginx を起動中:                                            [  OK  ]

以上で、「nginxのエラー“increase server_names_hash_bucket_size”の対処方法」は終了です。

nginx の人気記事

  1. sudoユーザーを追加する方法
  2. Linux設定マニュアル
  3. Windows10上でLinuxを実行(Linux用Windowsサブシステム)
  4. Windows10にLinux(Ubuntu)をインストール

関連記事(一部広告含む)