0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【初心者向け】LinuxでApacheを使ったWebサイト立ち上げ手順

Last updated at Posted at 2025-05-10

はじめに

LinuxでWebサイトを立ち上げる手順について、今更感はあるかもしれませんが、
初めてApacheを扱う方向けに、分かりやすくまとめました。

※本記事では、OSのインストールが完了している状態からスタートします。
環境構築(例:https://olvtools.com/documents/linux-install)については割愛します。

1. 使用環境

以下の環境で検証を行いました:

  • 仮想環境:VirtualBox
  • OS:Rocky Linux 9.5

OS確認コマンド:

$ cat /etc/redhat-release
Rocky Linux release 9.5 (Blue Onyx)

2. Apacheのインストール

$ sudo dnf install httpd -y

3. Apacheの起動および自動起動設定

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

4. ファイアウォールでポート80を許可

今回は firewalld を使用してポートを開放します。
(※環境によっては nftables など別の仕組みが使われている場合もあります。)

$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --reload

5. HTMLファイルの配置

index.html を作成し、"Hello World" を表示させます。

$ sudo mkdir -p /var/www/html
$ echo "<h1>Hello World</h1>" | sudo tee /var/www/html/index.html

6. ブラウザでの動作確認

サーバのIPアドレスをブラウザで開いてください:

http://<サーバのIPアドレス>

「Hello World」と表示されれば成功です。

※IPアドレスの確認コマンドはこちら:

$ ip a
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?