LoginSignup
0
2

More than 5 years have passed since last update.

KVM上のゲストマシンをhttpサーバーにした勉強メモ

Posted at

ホストマシンからゲストマシンへhttp接続する方法を学ぶことが目的。

環境

KVM環境
ゲストマシン:fedora21.x86_64

手順

  1. httpdのインストール
  2. httpサービスの起動
  3. firewalldの設定
  4. telnetによる検証

1.httpdのインストール

ゲストマシンにhttpdをインストールする。

# yum install httpd

2.httpdサービスの起動

インストールしたhttpdサービスを起動する。

# systemctl start httpd

3.firewalldの設定

こちらの記事を参考にさせていただきました。
CentOS7のfirewalldをまじめに使うはじめの一歩(systemdも少し)

デフォルトゾーンを調べ、NICが割り当てられていることを確認する。

# firewall-cmd --get-default-zone
FedoraServer
# firewall-cmd --list-interfaces
eth0

デフォルトゾーンに、httpサービスを追加する。

# firewall-cmd --add-service=http --zone=FedoraServer --permanent
success
# systemctl reload firewalld

4.telnetによる検証

telnetでポート80にアクセスし、接続できたら成功。
ブラウザからもhttp接続できるようになっている。

# telnet xxx.xxx.xxx.xx 80
Trying xxx.xxx.xxx.xx...
Connected to xxx.xxx.xxx.xx.
Escape character is '^]'.

以下のようなメッセージが出る場合、失敗。

# telnet xxx.xxx.xxx.xx 80
Trying xxx.xxx.xxx.xx...
telnet: Unable to connect to remote host: No route to host

ssh接続が出来たり、pingが通るにもかかわらず上記のメッセージが出るようであれば
firewalldの設定をもう一度見直す。

参考

システム管理者のガイド 第12章 WEBサーバー
CentOS7のfirewalldをまじめに使うはじめの一歩(systemdも少し)

0
2
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
2