BusyBox HTTPD で Drupal を動かそう
公開しないサーバーでローカルでウェブアプリケーション等を利用したい場合、Apacheのように大規模なサーバーソフトは必要なく小規模な物が欲しい。
そこで小さいウェブサーバーとしてNginx,Lighttpd,Chrokeeが候補に上がりますがBusyBoxも利用価値は高いです。デスクトップ用のネットワークアドレスはDMZの外に置くなど外部から80ポートにアクセス出来ないよう工夫しておきましょう。
管理画面
アカウント情報
サイトの状態
404エラーページ
- まずBusyBoxのhttpdアプレットを有効にしてビルドします。
- PHPのCGIを有効にしてビルドします。
- MySQL, PostgreSQL, SQLiteのいずれかのデータベースをインストールします
- php.iniを編集します。
cgi.force.redirect=0 cgi.redirect_status_env = "yes";
- busyboxバイナリのインストール先: /bin/busybox
- httpd 関連の置き場所: /usr/local
- ドキュメントルート: /srv/www/htdocs
# mkdir -p /usr/local/etc/init.d # ln -s ../usr/local/etc /etc/local # mkdir -p /usr/local/sbin # ln -s ../../../bin/busybox /usr/local/sbin/httpdこれで下準備が整いました。次にブートスクリプトを書きます。書式はディストリによって違いますのでここではGentooで使用するopenrcのブートスクリプトを紹介します。 ※ Gentooではopenrcを利用しています。openrcをインストールしていないGentooシステムでも書式が違ってくると思います。
# cat > /etc/local/init.d/httpd <<"EOF"
#!/sbin/runscript
extra_commands="init"
extra_started_commands=""
init() {
opts="-c /etc/local/httpd.conf -v"
}
# 依存関係
depend() {
need net
}
# サービスを起動するために必要なコマンド群
start() {
init
ebegin "Starting BusyBox HTTP Server"
echo "Options: httpd ${opts}"
export SERVER_NAME=localhost
start-stop-daemon --start \
--exec /usr/local/sbin/httpd \
-- ${opts}
/usr/bin/pgrep -x -u 0 -P 1 httpd > /var/run/busybox-httpd.pid
eend $?
}
# サービスを停止するために必要なコマンド群
stop() {
ebegin "Stopping BusyBox HTTP Server"
unset SERVER_NAME
start-stop-daemon --retry 20 --stop --exec /usr/local/sbin/httpd \
--pidfile /var/run/busybox-httpd.pid
eend $?
}
# サービスを再スタートするために必要なコマンド群
restart() {
stop
sleep 5
start
}
EOF
# chmod 700 /etc/local/init.d/httpd最後にhttpd.confを/etc/localに書きます。busyboxのソースツリーでhttpd.cの先頭をみればサンプルが書いています。
# cat > /etc/local/httpd.conf << "EOF" H:/srv/www/htdocs E404:/srv/www/error/404.html I:index.php .asp:text/html .svg:image/svg+xml .png:image/png .gif:image/gif .jpg:image/jpg *.php:/usr/bin/php-cgi EOF/srv/www/error/404.htmlは404エラーを返すときのHTMLファイルです。これも用意されていませんのでお洒落な404ページを作成してください。ここまでくれば完成ですのでブートスクリプトを起動するだけです。
# /etc/local/init.d/httpd startトップページ
管理画面
アカウント情報
サイトの状態
404エラーページ
トップページのテーマはStarkを書き換えたものです。 管理テーマはSevenを6.x用に書き換えたものです。 Drupal7は重くindex.phpのリダイレクトが複雑なので6.22を選びました。





コメント
コメントを投稿