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?

More than 3 years have passed since last update.

CentOS7のポート開放手順

Posted at

概要

ポート開放の手順

  1. Apacheで開放するポートを Listen する
  2. 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:
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?