概要
ポート開放の手順
- Apacheで開放するポートを Listen する
- firewalldのポートを開ける
今回は例としてポート 81番 を開放します。
環境
OS:CentOS7
Apache:2.4.6
1. Apacheで開放するポートを Listen する
httpd.conf に Listen するポートを設定します。
「/etc/httpd/conf/httpd.conf」を開いてください。
以下のように「Listen 81」を追記します。
/etc/httpd/conf/httpd.conf
====中略====
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
# Listen 12.34.56.78:80
Listen 80
Listen 81 ←ここに追加
====中略====
httpdを再起動します。
# service httpd restart
2. firewalldのポートを開ける
firewalldのポートを開けるには次のコマンドを実行します。
# firewall-cmd --zone=public --add-port=81/tcp --permanent
firewalldの設定を確認します。
「ports: 81」が表示されていればオッケーです。
# firewall-cmd --list-all
public (default, active)
interfaces: enp0s3 enp0s8 enp0s9
sources:
services: dhcpv6-client http ssh
ports: 81/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules: