Httpd Port

  1. 查看 httpd 服務的狀態,enabled (開機啟動),Active:failed (啟動失敗)。 從狀態說明,查到原因是無法啟動在 82 port。
    [root@kvm8 ~]# systemctl status httpd.service 
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; 
    vendor preset: disabled)
       Active: failed (Result: exit-code) since Wed 2019-11-06 21:01:25 CST; 
    1min 53s ago
         Docs: man:httpd.service(8)
      Process: 1961 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND 
    (code=exited, status=1/FAILURE)
     Main PID: 1961 (code=exited, status=1/FAILURE)
       Status: "Reading configuration..."
    
    Nov 06 21:01:25 kvm8.deyu.wang systemd[1]: Starting The Apache HTTP Server...
    Nov 06 21:01:25 kvm8.deyu.wang httpd[1961]: (13)Permission denied: AH00072: 
    make_sock: could not bind to address [::]:82
    Nov 06 21:01:25 kvm8.deyu.wang httpd[1961]: (13)Permission denied: AH00072: 
    make_sock: could not bind to address 0.0.0.0:82
    Nov 06 21:01:25 kvm8.deyu.wang httpd[1961]: no listening sockets available, 
    shutting down
    Nov 06 21:01:25 kvm8.deyu.wang httpd[1961]: AH00015: Unable to open logs
    Nov 06 21:01:25 kvm8.deyu.wang systemd[1]: httpd.service: Main process exited, 
    code=exited, status=1/FAILURE
    Nov 06 21:01:25 kvm8.deyu.wang systemd[1]: httpd.service: Failed with result 
    'exit-code'.
    Nov 06 21:01:25 kvm8.deyu.wang systemd[1]: Failed to start The Apache HTTP 
    Server.
    
  2. 查詢 http_port_t,82 port 不是 httpd 程序允許訪問的 port。
    [root@kvm8 ~]# semanage port -l | grep ^http_port
    http_port_t           tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
    
  3. 新增 82 為 httpd 服務允許訪問的埠號。
    [root@kvm8 ~]# semanage port -a -t http_port_t -p tcp 82
    
  4. 再查詢 http_port_t,82 port 已經是 httpd 程序允許訪問的 port。
    [root@kvm8 ~]# semanage port -l | grep ^http_port
    http_port_t           tcp      82, 80, 81, 443, 488, 8008, 8009, 8443, 9000
    
  5. 再重新啟動 httpd 服務,成功啟動服務。
    [root@kvm7 html]# systemctl restart httpd.service
    
  6. 再查看 httpd 服務的狀態,enabled (開機啟動),Active: active (running)。
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2019-11-06 21:15:06 CST; 5s ago
         Docs: man:httpd.service(8)
     Main PID: 15569 (httpd)
       Status: "Started, listening on: port 82"
        Tasks: 213 (limit: 11512)
       Memory: 30.9M
       CGroup: /system.slice/httpd.service
               ├─15569 /usr/sbin/httpd -DFOREGROUND
               ├─15570 /usr/sbin/httpd -DFOREGROUND
               ├─15571 /usr/sbin/httpd -DFOREGROUND
               ├─15572 /usr/sbin/httpd -DFOREGROUND
               └─15573 /usr/sbin/httpd -DFOREGROUND
    
    Nov 06 21:15:06 kvm8.deyu.wang systemd[1]: Starting The Apache HTTP Server...
    Nov 06 21:15:06 kvm8.deyu.wang httpd[15569]: Server configured, listening on: port 82
    Nov 06 21:15:06 kvm8.deyu.wang systemd[1]: Started The Apache HTTP Server.