Centos

無法可靠地確定伺服器的完全限定域名

  • January 18, 2018

我正在按照教程在 Centos 7 中設置兩個虛擬主機。

問題是我在重新啟動 httpd 時收到以下錯誤。

[userme@server ~]$ sudo systemctl restart httpd.service 
[sudo] password for userme: 
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

我的配置是

[userme@server ~]$ cat /etc/hosts
127.0.0.1   server.workstation.com server
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

[userme@server ~]$ hostname
server.workstation.com

[userme@server ~]$ cat /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=server


[userme@server ~]$ cat /etc/resolv.conf 
# Generated by NetworkManager
search workstation.com
nameserver fe80::1%p3p1
nameserver 192.168.100.1


[userme@server ~]$ domainname 
(none)

編輯根據要求

[userme@server ~]$ systemctl status httpd -l
● httpd.service - The Apache HTTP Server
  Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Active: failed (Result: exit-code) since Thu 2018-01-18 12:55:25 +04; 57min ago
    Docs: man:httpd(8)
          man:apachectl(8)
 Process: 1285 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
 Process: 1283 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 1283 (code=exited, status=1/FAILURE)

Jan 18 12:55:25 server.workstation.com systemd[1]: Starting The Apache HTTP Server...
Jan 18 12:55:25 server.workstation.com httpd[1283]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using server.workstation.com. Set the 'ServerName' directive globally to suppress this message
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 18 12:55:25 server.workstation.com kill[1285]: kill: cannot find process ""
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 18 12:55:25 server.workstation.com systemd[1]: Failed to start The Apache HTTP Server.
Jan 18 12:55:25 server.workstation.com systemd[1]: Unit httpd.service entered failed state.
Jan 18 12:55:25 server.workstation.com systemd[1]: httpd.service failed.


[userme@server ~]$ sudo firewall-cmd --list-all
public (active)
 target: default
 icmp-block-inversion: no
 interfaces: p3p1
 sources: 
 services: ssh dhcpv6-client
 ports: 
 protocols: 
 masquerade: no
 forward-ports: 
 source-ports: 
 icmp-blocks: 
 rich rules:

[userme@server ~]$ apachectl configtest
Syntax OK

我的網路/主機名設置有什麼問題?任何幫助,將不勝感激。

這看起來像是在 CentOS 7 上預設啟用的 SELINUX 的問題。

設置SELINUX=permissive並重新啟動伺服器會將問題記錄到 /var/log/audit/audit.log 以便設置適當的 SELINUX 設置以允許 SELINUX 保護伺服器。

此外,還需要設置firewalld允許訪問埠 80 和 443 以允許外部連接:

firewall-cmd --add-service=http
firewall-cmd --add-service=https

linode 為 firewalld 寫了一篇很好的文章,但我還沒有找到一個好的 SELINUX 資源……

引用自:https://unix.stackexchange.com/questions/417967