Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【2026年版】WindowsにApacheをインストールしてWebサーバーを構築する

1
Posted at

はじめに

本記事では、Apache HTTP Serverのインストールから
基本的な設定・操作コマンドまでの手順をまとめます。

FlaskなどのPythonフレームワークを本番環境で動かす際、
Apacheと組み合わせて使用するケースが多いです。
本記事はその前段として、Apacheの導入手順をカバーします。

Flaskの組み込みサーバーは開発用です。
本番環境ではApacheなどのWebサーバーを使用してください。

対象読者

  • WindowsにApacheを導入したい方
  • FlaskアプリをApacheで動かす準備をしたい方

実行環境

項目 内容
OS Windows 11
Apache 2.4系(最新安定版)

Apacheとは

Apache HTTP Serverは、オープンソースのWebサーバーソフトウェアです。
世界シェアが高く、Flask・Djangoなど
PythonベースのフレームワークをApache上で動かす際は
mod_wsgiモジュールを組み合わせて使用します。

特徴 内容
ライセンス オープンソース・無料
対応OS Windows / Linux / macOS
拡張性 モジュール追加で機能を柔軟に拡張可能
実績 豊富なドキュメントとコミュニティ

Apacheのインストール

コマンドプロンプトは管理者として実行してください。

1. インストーラーのダウンロード

Apache公式サイトはLinux向けのソースのみ配布しています。
Windows用バイナリはApacheLoungeから入手します。

Win64欄から最新のhttpd-2.4.xx-win64-VSxx.zipをダウンロードし、解凍します。

2. ファイルの配置

解凍したフォルダ内のApache24フォルダを
C:\Apache24に配置します。

C:\Apache24\
  ├── bin\
  ├── conf\
  ├── htdocs\
  └── logs\

3. サービスとして登録

管理者権限のコマンドプロンプトでbinフォルダに移動し、実行します。

cd C:\Apache24\bin
httpd -k install

成功すると、ApacheがWindowsサービスとして登録されます。

登録に失敗する場合は、サービス名と設定ファイルのパスを明示して実行してください。

httpd.exe -k install -n "Apache2.4" -f "C:/Apache24/conf/httpd.conf"

4. 動作確認

httpd -k start

ブラウザで http://localhost にアクセスし、
It works! と表示されれば完了です。


基本コマンド一覧

実行前に必ず C:\Apache24\bin へ移動し、管理者権限で実行してください。

確認系

コマンド 説明 備考
httpd -t 設定ファイルの文法チェック Syntax OK なら問題なし
httpd -S バーチャルホスト設定の確認 ServerNameとポート番号を確認できる
httpd -M ロード中のモジュール一覧表示 mod_wsgiの確認にも使う

起動・停止系

コマンド 説明 備考
httpd -k start 起動
httpd -k stop 強制停止 処理中のリクエストも即終了
httpd -k restart 強制再起動
httpd -k graceful-stop 安全な停止 処理中のリクエストを完了してから停止
httpd -k graceful 安全な再起動 処理中のリクエストを完了してから再起動

インストール・アンインストール系

コマンド 説明
httpd -k install Windowsサービスとして登録
httpd -k uninstall Windowsサービスから削除

まとめ

ApacheをWindowsサービスとして登録することで、
PC起動時の自動起動と安定した常駐運用が実現できます。

次のステップとして、mod_wsgiを導入することで
FlaskアプリをApache上で動かすことができます。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

@Choco0602's pickup articles

Choco0602

@Choco0602

業務でPython・SQLite・Flaskを使ったシステム開発・運用を担当しており、学んだことや実務で使った技術をQiitaに記録しています。 趣味でGO言語の学習を行なっています。 ↓𝕏のアカウントです。 https://x.com/CHOCO_python6

Comments

No comments

Let's comment your feelings that are more than good

Qiita Conference 2026 will be held!: 5/27(Wed) - 5/29(Fri)

Qiita Conference is Qiita's largest tech conference, dedicated to engineers in the age of AI!

Speakers

Takuya Oikawa, Tsuyoshi Ushio, Daichi Hiroki, Masahiro Nishimi, Minorun, and 12 guests in total!

View event details

Being held Article posting campaign

みんなでRubyの知見を共有しよう

2026-04-13 ~ 2026-05-10

View details
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address