SBクラウドでApacheサーバを構築する

2017年05月20日

1. CentOSを更新する。

#yum -y update

2. Apacheをインストールする。

# yum -y install httpd

3. httpdサービスの状況を確認する。

# systemctl status httpd
	● httpd.service - The Apache HTTP Server
	   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
	   Active: inactive (dead)
	     Docs: man:httpd(8)
	           man:apachectl(8)

4. 80ポートの状況を確認する。

# netstat -nat
	Active Internet connections (servers and established)
	Proto Recv-Q Send-Q Local Address           Foreign Address         State
	tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
	tcp        0    316 172.24.217.22:22        114.158.185.111:62166   ESTABLISHED

ssで確認する

# ss -nat
	State      Recv-Q Send-Q    Local Address:Port                   Peer Address:Port
	LISTEN     0      128                   *:22                                *:*
	ESTAB      0      80        172.24.217.22:22                      87.3.22.130:44841
	ESTAB      0      204       172.24.217.22:22                  114.158.185.111:62166
	ESTAB      0      1640      172.24.217.22:22                   113.195.145.21:32508

5. httpdサービスを起動する。

# systemctl start httpd.service
	● httpd.service - The Apache HTTP Server
	   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
	   Active: active (running) since Sat 2017-05-20 18:52:33 CST; 1min 30s ago
	     Docs: man:httpd(8)
	           man:apachectl(8)
	 Main PID: 5060 (httpd)
	   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
	   CGroup: /system.slice/httpd.service
	           ├─5060 /usr/sbin/httpd -DFOREGROUND
	           ├─5061 /usr/sbin/httpd -DFOREGROUND
	           ├─5062 /usr/sbin/httpd -DFOREGROUND
	           ├─5063 /usr/sbin/httpd -DFOREGROUND
	           ├─5064 /usr/sbin/httpd -DFOREGROUND
	           └─5065 /usr/sbin/httpd -DFOREGROUND

	May 20 18:52:33 iz6we0st6pqhts99lg7d51z systemd[1]: Starting The Apache HTTP Server...
	May 20 18:52:33 iz6we0st6pqhts99lg7d51z httpd[5060]: AH00558: httpd: Could not reliably deter...ge
	May 20 18:52:33 iz6we0st6pqhts99lg7d51z systemd[1]: Started The Apache HTTP Server.
	Hint: Some lines were ellipsized, use -l to show in full.
	
	# systemctl enable httpd.service
	Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

6.ポートの LISTEN 状態を確認する。

# ss -nat
	State      Recv-Q Send-Q    Local Address:Port                   Peer Address:Port
	LISTEN     0      128                   *:80                                *:*
	LISTEN     0      128                   *:22                                *:*
	ESTAB      0      204       172.24.217.22:22                  114.158.185.111:62166
	ESTAB      0      0         172.24.217.22:22                   113.195.145.21:19575

7.ファイアウォール状況を確認する。
	# iptables -L
	Chain INPUT (policy ACCEPT)
	target     prot opt source               destination

	Chain FORWARD (policy ACCEPT)
	target     prot opt source               destination

	Chain OUTPUT (policy ACCEPT)
	target     prot opt source               destination

	# systemctl status firewalld
	● firewalld.service - firewalld - dynamic firewall daemon
	   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
	   Active: inactive (dead)
	     Docs: man:firewalld(1)

8.ファイアウォールを起動する。

# systemctl start firewalld
	# systemctl status firewalld
	● firewalld.service - firewalld - dynamic firewall daemon
	   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
	   Active: active (running) since Sat 2017-05-20 19:09:41 CST; 3s ago
	     Docs: man:firewalld(1)
	 Main PID: 5318 (firewalld)
	   CGroup: /system.slice/firewalld.service
	           └─5318 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

	May 20 19:09:41 iz6we0st6pqhts99lg7d51z systemd[1]: Starting firewalld - dynamic firewall dae.....
	May 20 19:09:41 iz6we0st6pqhts99lg7d51z systemd[1]: Started firewalld - dynamic firewall daemon.
	Hint: Some lines were ellipsized, use -l to show in full.

	# systemctl enable httpd.service
	Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

9. http, httpsを有効にする。

# firewall-cmd --add-service=http --zone=public --permanent
	success
	# firewall-cmd --add-service=https --zone=public --permanent
	success
	# firewall-cmd --reload
	success

10. 動作を確認する。
WS000000