Cygwin - Apache2 インストール!

Updated:


今日は Cygwin に Web サーバ Apache2 環境を構築しました。

以下、作業記録です。

作業記録

1.Apache2 インストール

Cygwin の setup.exe から apache2 をインストールする。 もしくは、パッケージ管理 apt-cyg を導入済みなら、以下のようにしてインストールする。

$ apt-cyg install apache2

2.cygrunsrv インストール

UNIX デーモンプログラムを Windows NT/2000/XP 上のサービスとして動作させるためのパッケージ cygrunsrv を Cygwin の setup.exe からインストールする。 もしくは、パッケージ管理 apt-cyg を導入済みなら、以下のようにしてインストールする。

$ apt-cyg install cygrunsrv

3.環境変数設定

動作に必要な環境変数 CYGWIN を設定します。 Cygwin フォルダ配下にある Cygwin.bat に以下の1行を追加します。

set CYGWIN=server

4.サービス登録

Windows のサービスとして起動させるために以下のコマンド実行します。 サービスとして起動するかどうかの質問には “yes” と応答します。 ※サービスとして起動しないのであれば “no” と応答します。

$ cygserver-config
Generating /etc/cygserver.conf file

Warning: The following function requires administrator privileges!

Do you want to install cygserver as service?
(Say "no" if it's already installed as service) (yes/no) yes

The service has been installed under LocalSystem account.
To start it, call `net start cygserver' or `cygrunsrv -S cygserver'.

Further configuration options are available by editing the configuration
file /etc/cygserver.conf.  Please read the inline information in that
file carefully. The best option for the start is to just leave it alone.

Basic Cygserver configuration finished. Have fun!

5.サービス起動

登録したサービスを起動します。 前述のサービス登録時のメッセージにもあるように “net start cygserver” か “cygrunsrv -S cygserver” と実行します。

$ cygrunsrv -S cygserver

“Bad system call” と出力されなければ成功です。

6.Apache 設定ファイル編集

Apache 設定ファイル /etc/apache2/httpd.conf に以下の記述を追加します。

User Guest
Group Guests 

7.Apache 起動

Apache2 を起動します。

$ /usr/sbin/apachectl2 start

Apache2 起動時に

httpd2: Could not reliably determine the server's fully 
qualified domain name, using 192.168.11.13 for ServerName

などと出力される場合、”/etc/apache2/httpd.conf” に ServerName が設定されていないためなので、ServerNameを設定する。

(112)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

などと出力される場合、ソケットが既に使われているためなので、”/etc/apache2/httpd.conf” の Listen を明示的に記述する。

8.動作確認

Web ブラウザで “http://127.0.0.1/” もしくは “http://localhost/” にアクセスしてみて “It works!” と表示されれば成功です。

9.Apache 終了

Apache2 を終了します。

$ /usr/sbin/apachectl2 stop

10.サービスの終了

起動しているサービスを終了します。

$ cygrunsrv -E cygserver

以上です。





 

Sponsored Link

 

Comments