Raspberry Pi上にWebサーバを導入して、Apache初期サイトにアクセスしてみる。
■本日の目標
Raspberry Pi 3にApache HTTPサーバを導入する
■主な作業環境
・HW:Raspberry Pi 3 Model B
・OS:CentOS Linux release 7.9.2009 (AltArch)
・OS:CentOS Linux release 7.9.2009 (AltArch)
■httpdの情報を確認する
$ yum info httpd 利用可能なパッケージ 名前 : httpd アーキテクチャー : armv7hl バージョン : 2.4.6 リリース : 97.el7.centos 容量 : 2.7 M リポジトリー : updates/7/armhfp 要約 : Apache HTTP Server URL : http://httpd.apache.org/ ライセンス : ASL 2.0 説明 : The Apache HTTP Server is a powerful, efficient, and extensible web server.
少々心配したが、ちゃんとリポジトリに存在するようだ。
■httpdをインストールする
$ yum install httpd base | 3.6 kB 00:00:00 centos-kernel | 2.9 kB 00:00:00 epel | 3.8 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ httpd.armv7hl 0:2.4.6-97.el7.centos を インストール --> 依存性の処理をしています: httpd-tools = 2.4.6-97.el7.centos のパッケージ: httpd-2.4.6-97.el7.centos.armv7hl --> 依存性の処理をしています: /etc/mime.types のパッケージ: httpd-2.4.6-97.el7.centos.armv7hl --> トランザクションの確認を実行しています。 ---> パッケージ httpd-tools.armv7hl 0:2.4.6-97.el7.centos を インストール ---> パッケージ mailcap.noarch 0:2.1.41-2.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ======================================================================================= Package アーキテクチャー バージョン リポジトリー 容量 ======================================================================================= インストール中: httpd armv7hl 2.4.6-97.el7.centos updates 2.7 M 依存性関連でのインストールをします: httpd-tools armv7hl 2.4.6-97.el7.centos updates 95 k mailcap noarch 2.1.41-2.el7 base 31 k トランザクションの要約 ======================================================================================= インストール 1 パッケージ (+2 個の依存関係のパッケージ) 総ダウンロード容量: 2.8 M インストール容量: 9.2 M Is this ok [y/d/N]: y Downloading packages: (1/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00 (2/3): httpd-tools-2.4.6-97.el7.centos.armv7hl.rpm | 95 kB 00:00:01 (3/3): httpd-2.4.6-97.el7.centos.armv7hl.rpm | 2.7 MB 00:00:04 ----------------------------------------------------------------------------------- 合計 561 kB/s | 2.8 MB 00:00:05 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : httpd-tools-2.4.6-97.el7.centos.armv7hl 1/3 インストール中 : mailcap-2.1.41-2.el7.noarch 2/3 インストール中 : httpd-2.4.6-97.el7.centos.armv7hl 3/3 検証中 : httpd-2.4.6-97.el7.centos.armv7hl 1/3 検証中 : mailcap-2.1.41-2.el7.noarch 2/3 検証中 : httpd-tools-2.4.6-97.el7.centos.armv7hl 3/3 インストール: httpd.armv7hl 0:2.4.6-97.el7.centos 依存性関連をインストールしました: httpd-tools.armv7hl 0:2.4.6-97.el7.centos mailcap.noarch 0:2.1.41-2.el7 完了しました!
■httpdのバージョンを確認する
$ httpd -version Server version: Apache/2.4.6 (CentOS) Server built: Nov 16 2020 16:26:22
■httpdサービスを自動起動化する
$ systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
■httpdサービスを起動する
$ systemctl start httpd $ systemctl -l status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 土 2021-01-23 17:05:30 JST; 1min 45s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 14626 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service tq14626 /usr/sbin/httpd -DFOREGROUND tq14627 /usr/sbin/httpd -DFOREGROUND tq14628 /usr/sbin/httpd -DFOREGROUND tq14629 /usr/sbin/httpd -DFOREGROUND tq14630 /usr/sbin/httpd -DFOREGROUND mq14631 /usr/sbin/httpd -DFOREGROUND 1月 23 17:05:30 WSTD-RPI3 systemd[1]: Starting The Apache HTTP Server... 1月 23 17:05:30 WSTD-RPI3 httpd[14626]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.100. Set the 'ServerName' directive globally to suppress this message 1月 23 17:05:30 WSTD-RPI3 systemd[1]: Started The Apache HTTP Server.
■firewalldに80番ポート(httpdのデフォルトポート)の通信許可を行う
firewalldが起動している場合はファイアウォールに穴をあけてあげれば良い。
$ firewall-cmd --add-service=http --zone=public --permanent success $ firewall-cmd --reload success
■WebブラウザでApache初期サイトにアクセスする
■AH00558エラー対策
起動時にスルーしてたAH00558のエラーメッセージを対処する。
メッセージを読む限り、ServerNameの指定が無いと言うことでエラーを吐いているようだ。
なので、設定ファイル(/etc/httpd/conf/httpd.conf)にServerNameを記述してあげれば良い。
メッセージを読む限り、ServerNameの指定が無いと言うことでエラーを吐いているようだ。
なので、設定ファイル(/etc/httpd/conf/httpd.conf)にServerNameを記述してあげれば良い。
$ vi /etc/httpd/conf/httpd.conf 変更前:#ServerName www.example.com:80 変更後:ServerName www.example.com:80 ※とりあえずコメントアウトを解除するだけ。 $ systemctl restart httpd $ systemctl -l status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 土 2021-01-23 17:22:23 JST; 5s ago Docs: man:httpd(8) man:apachectl(8) Process: 14943 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS) Main PID: 14948 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service tq14948 /usr/sbin/httpd -DFOREGROUND tq14949 /usr/sbin/httpd -DFOREGROUND tq14950 /usr/sbin/httpd -DFOREGROUND tq14951 /usr/sbin/httpd -DFOREGROUND tq14952 /usr/sbin/httpd -DFOREGROUND mq14953 /usr/sbin/httpd -DFOREGROUND 1月 23 17:22:23 WSTD-RPI3 systemd[1]: Starting The Apache HTTP Server... 1月 23 17:22:23 WSTD-RPI3 systemd[1]: Started The Apache HTTP Server.
エラーメッセージが消えた。
正常に画面表示はできていたけど、エラーを起こした状態で放置したくなかったので。
これにて終了。
正常に画面表示はできていたけど、エラーを起こした状態で放置したくなかったので。
これにて終了。