さくらのVPSにLighttpd+PHPをインストール その1
今度は、さくらのVPSにLighttpd+PHPをインストールしてみたので、インストール時のメモ。OSは、前回と同じくCentOS5なので、基本的には、WebARENA CLOUD9にLighttpd+PHPをインストール その1の時と同じ。前回は、すでにApache+PHP環境だったのをyum removeしてからのインストールだったのが、今回は、さくらのVPSをセットアップした直後の作業だったので、今回の方が例外が少ないと思う。
参考サイト
Lighttpdのサイトを主に参考にした。ドキュメントは英文だけど、そんなにややこしくないので大丈夫。
Lighttpd – WikiStart – lighty labs
http://redmine.lighttpd.net/wiki/lighttpd
Lighttpdのインストール
ソースを、http://www.lighttpd.net/download/からダウンロードする。インストールした時点での最新版は、1.4.28。
サーバ上で以下の手順を実施。
#tar -zxvf lighttpd-1.4.28.tar.gz #cd lighttpd-1.4.28 #./configure \ --without-zlib \ --without-bzip2 \ --disable-ipv6
ここで、configure: error: pcre-config not found, install the pcre-devel package or build with –without-pcre のエラーが出たので、pcre-develをインストールして再度実行。
#yum install pcre-devel #./configure \ --without-zlib \ --without-bzip2 \ --disable-ipv6 #make #make install
インストール後の設定は、http://redmine.lighttpd.net/wiki/lighttpd/InstallFromSource#Init-scriptの項目に沿って実施する。
サーバがCentOSなので
#sed -e 's/FOO/lighttpd/g' doc/initscripts/rc.lighttpd.redhat > /etc/init.d/lighttpd #chmod a+rx /etc/init.d/lighttpd #cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd #mkdir -p /etc/lighttpd #cp -R doc/config/conf.d/ doc/config/*.conf doc/config/vhosts.d/ /etc/lighttpd/ #chkconfig lighttpd on
起動スクリプト中のサーバのパスが /usr/sbin/lighttpd で、実際のインストールパスが /usr/local/sbin/lighttpd なので、シンボリックリンクを作成。
#ln -s /usr/local/sbin/lighttpd /usr/sbin/lighttpd
Lighttpdの設定
後でFastCGIやPHPはインストールするとして、Lighttpdがうまく動くかを確認。色々な仕組みを一緒に使う時は、ひとつひとつ動くことを確認しながら進めると意外とはまらない。設定については、http://redmine.lighttpd.net/wiki/lighttpd/TutorialConfigurationで大まかな設定例があり、それに沿えば良い。
#vi /etc/lighttpd/lighttpd.conf var.log_root = "/var/log/httpd" ←apacheと同じ場所に設定 server.port = 80 ←サーバのポート。apacheがポート80でまだ動いているような場合は別のポートにする必要がある server.username = "nobody" ←デフォルトで lighttp になっているが、ユーザもグループも作っていないので nobody にした server.groupname = "nobody" server.document-root = "/var/www/public_html" ←デフォルトのドキュメントルートを設定
実行ユーザをnobodyにしたので、ログディレクトリ /var/log/httpd がnobodyでアクセス出来るよう設定する。
#chown nobody:nobody /var/log/httpd
ここまでの設定でひとまずLighttpdは動く、はず。
#service lighttpd start
apacheのようにデフォルトページが用意されていないので、最初は何も表示されない。自前でindex.htmlを作ってドキュメントルートにアップして確認する。