0
0

More than 1 year has passed since last update.

Apacheを起動してもブラウザから見られないという罠 --20年(?)ぶりにLinuxをいじってみる03

Last updated at Posted at 2023-01-18

全8回の3 → 1|2|3|4|5|6|7|8

Webサーバーはインストール時にApacheを(どうせNginxとか使わないし)入れていたので、まずはhttpd.confをいじってServerNameをIPアドレスにしておく。

$ sudo systemctl start httpd

行けたかな?

$ systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
     Active: active (running) since Mon 2022-12-05 20:17:14 JST; 4min 25s ago
       Docs: man:httpd.service(8)
   Main PID: 2001 (httpd)
     Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
      Tasks: 214 (limit: 74497)
     Memory: 38.4M
        CPU: 186ms
     CGroup: /system.slice/httpd.service
             ├─2001 /usr/sbin/httpd -DFOREGROUND
             ├─2002 /usr/sbin/httpd -DFOREGROUND
             ├─2003 /usr/sbin/httpd -DFOREGROUND
             ├─2004 /usr/sbin/httpd -DFOREGROUND
             ├─2005 /usr/sbin/httpd -DFOREGROUND
             └─2006 /usr/sbin/httpd -DFOREGROUND

12月 05 20:17:14 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
12月 05 20:17:14 localhost.localdomain httpd[2001]: Server configured, listening on: port 443, port 80
12月 05 20:17:14 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

行けたね。
あとは/var/www/html/に適当にファイルを置いてブラウザからアクセス。

…拒否られた。
調べてみたらこれか。

デフォルトのファイアウォールの設定では、Webサーバーへのアクセスは許可されません。
そのため、Apacheを起動しただけでは外部からアクセスはできないので、ファイアウォールの設定を変更し、80番ポートのアクセスを許可します。
ファイアウォールの設定では、firewall-cmd コマンドを使います。

$ sudo firewall-cmd --permanent --add-service=http
success
$ sudo firewall-cmd --reload
success
スクリーンショット

できた。
う~ん、こんなに面倒だったかな~。覚えてないや。


追記。これを忘れてた。

$ sudo systemctl enable httpd
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