kurukuru-papaのブログ

主に、ソフトウェア開発に関連したメモを書き溜めたいと思います。

(Cygwin)Apache2の導入

Cygwin環境にApache2を導入してみましたので、メモしておきます。ポイントは、下記2の手順です。これがなかなかわからなくて途方にくれてしまいました。

1.Apacheのインストール

Cygwinのsetup.exeを起動し、パッケージの選択画面まで遷移し、Netカテゴリーから、apache2, apache2-devel, apache2-manualをインストール対象に追加しました。バージョンは2.2.6-1となりました。

この時点で、Apacheを起動しようとするとエラーとなりました。

$ /usr/sbin/httpd2.exe
httpd2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.21 for ServerName
Bad system call

2.Cygwinをサーバとして機能するように設定する?

よくわからなかったのですが、ネットを調べると次の2つのコマンドで設定を行う必要があるようです。

  1. cygserver-config
  2. net start cygserver

なお、これらを実行するには、cygrunsrvが必要だったので、Cygwinのsetup.exeからインストールしておきました。

cygserver-configを実行すると、Windowsのサービスとして動作させるか聞かれましたので、「yes」と答えました。さらに、環境変数CYGWINに「server」を追加するようにメッセージが出ましたので、"ntsec server"を設定しました。

$ 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.

Please keep in mind, that a client application which wants to use
the services provided by cygserver *must* have the environment variable
CYGWIN set so that it contains the word "server". So, if you don't
need any other special CYGWIN setting, just set it to "server".

It is advisable to add this setting to the Windows system environment.

Basic Cygserver configuration finished. Have fun!

net start cygserverを実行すると、サービスが開始されれた旨、メッセージ出力されました。

$ net start cygserver
CYGWIN cygserver サービスを開始します.
CYGWIN cygserver サービスは正常に開始されました。

3.Apacheの起動

次のコマンドで、起動する事が出来ました。

$ /usr/sbin/httpd2 -k start
httpd2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.21 for ServerName

設定ファイルをいじっていなかったので、ワーニングが出てしまいました。でも、ブラウザから「http://localhost/」としてアクセスすると、「It works!」と言う文字が画面に表示され、正常動作を確認できました。