カジュアルに静的ファイルを公開するためにhttpサーバーが欲しく、lighttpdをAmazon Linuxにインストールしました。
yumで簡単にインストールできますが、デフォルトの設定だとwarningが出るため設定を一部変更します。
yumでインストール
sudo yum install lighttpd
起動
sudo /etc/init.d/lighttpd start
2015-12-02 09:03:27: (network.c.283) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes
2015-12-02 09:03:27: (server.c.927) can't have more connections than fds/2: 1024 1024
なんかwarningでました。そのままでも起動して使えるようですが、気持ち悪いのでコンフィグを修正。
コンフィグ修正
- ipv6は使わないのでdisableに。
- ファイルディスクリプタの最大数を超えているようなので調整。起動スクリプトでファイルディスクリプタの数を増やしてもいのですが、適当に動かしたいだけなのでファイルディスクリプタを減らす設定を入れました。
デフォルトのファイルディスクリプタ数は1024。max-connectionsの二倍の数が必要なので、512に設定します。
$ ulimit -n
1024
下記の変更を加える
sudo vim /etc/lighttpd/lighttpd.conf
< server.use-ipv6 = "enable"
> server.use-ipv6 = "disable"
---
> server.max-connections = 512
< server.max-connections = 1024
確認
lighttpdを再起動し、動作を確認。
sudo /etc/init.d/lighttpd start
正しく起動しているようです。適当なhtmlファイルを置いて確認します。/var/www/lighttpd/
に配置。
sudo bash -c 'echo "hello lighttpd" > /var/www/lighttpd/test.html'
確認OK!
最後に自動起動をONにする
sudo chkconfig lighttpd on