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; preset: disabled)
         Active: failed (Result: exit-code) since Thu 2025-10-09 13:36:57 CST; 21min ago
     Invocation: 9032bd5315bf4dfc99ab9ee27cfd05d2
           Docs: man:httpd.service(8)
        Process: 800 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
       Main PID: 800 (code=exited, status=1/FAILURE)
         Status: "Reading configuration..."
       Mem peak: 7.6M
            CPU: 123ms
    
    Oct 09 13:36:56 kvm8.deyu.wang systemd[1]: Starting httpd.service - 
    The Apache HTTP Server...
    Oct 09 13:36:56 kvm8.deyu.wang (httpd)[800]: httpd.service: Referenced 
    but unset environment variable evaluates to an empty string: OPTIONS
    Oct 09 13:36:57 kvm8.deyu.wang httpd[800]: AH00558: httpd: Could not 
    reliably determine the server's fully qualified domain name, 
    using kvm8.deyu.wang. Set the 'ServerNam>
    Oct 09 13:36:57 kvm8.deyu.wang httpd[800]: (13)Permission denied: AH00072: 
    make_sock: could not bind to address [::]:82
    Oct 09 13:36:57 kvm8.deyu.wang httpd[800]: (13)Permission denied: AH00072: 
    make_sock: could not bind to address 0.0.0.0:82
    Oct 09 13:36:57 kvm8.deyu.wang httpd[800]: no listening sockets available, 
    shutting down
    Oct 09 13:36:57 kvm8.deyu.wang httpd[800]: AH00015: Unable to open logs
    Oct 09 13:36:57 kvm8.deyu.wang systemd[1]: httpd.service: Main process exited,
    code=exited, status=1/FAILURE
    Oct 09 13:36:57 kvm8.deyu.wang systemd[1]: httpd.service: Failed with result
    'exit-code'.
    Oct 09 13:36:57 kvm8.deyu.wang systemd[1]: Failed to start httpd.service -
    The Apache HTTP Server.
    
  2. 查詢 http_port_t,82 port 不是 httpd 程序允許訪問的 port。
    [root@kvm8 ~]# semanage port --list | grep http
    http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
    http_cache_port_t              udp      3130
    http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
    pegasus_http_port_t            tcp      5988
    pegasus_https_port_t           tcp      5989
    
  3. 新增 82 為 httpd 服務允許訪問的埠號。
    [root@kvm8 ~]# semanage port --add --type http_port_t --proto tcp 82
    
  4. 再查詢 http_port_t,82 port 已經是 httpd 程序允許訪問的 port。
    [root@kvm8 ~]# semanage port --list | grep http
    http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
    http_cache_port_t              udp      3130
    http_port_t                    tcp      82, 80, 81, 443, 488, 8008, 8009, 8443, 9000
    pegasus_http_port_t            tcp      5988
    pegasus_https_port_t           tcp      5989
    
  5. 再重新啟動 httpd 服務,成功啟動服務。
    [root@kvm8 ~]# systemctl restart httpd.service
    
  6. 再查看 httpd 服務的狀態,enabled (開機啟動),Active: active (running)。
    [root@kvm8 ~]# systemctl status httpd.service
    ● httpd.service - The Apache HTTP Server
         Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
         Active: active (running) since Thu 2025-10-09 14:04:50 CST; 2min 12s ago
     Invocation: 2b1a669432084054ba07537add6dcdc5
           Docs: man:httpd.service(8)
       Main PID: 1617 (httpd)
         Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
          Tasks: 177 (limit: 10692)
         Memory: 13.1M (peak: 13.3M)
            CPU: 607ms
         CGroup: /system.slice/httpd.service
                 ├─1617 /usr/sbin/httpd -DFOREGROUND
                 ├─1618 /usr/sbin/httpd -DFOREGROUND
                 ├─1619 /usr/sbin/httpd -DFOREGROUND
                 ├─1621 /usr/sbin/httpd -DFOREGROUND
                 └─1632 /usr/sbin/httpd -DFOREGROUND
    
    Oct 09 14:04:50 kvm8.deyu.wang systemd[1]: Starting httpd.service - 
    The Apache HTTP Server...
    Oct 09 14:04:50 kvm8.deyu.wang (httpd)[1617]: httpd.service: Referenced 
    but unset environment variable evaluates to an empty string: OPTIONS
    Oct 09 14:04:50 kvm8.deyu.wang httpd[1617]: Server configured, 
    listening on: port 82
    Oct 09 14:04:50 kvm8.deyu.wang systemd[1]: Started httpd.service - 
    The Apache HTTP Server.