page counter next up previous contents
Next: NFS Server Up: SELinux 管理 Confined 服務 Previous: Httpd SELinux Context   Contents   DYWANG_HOME

Httpd SELinux Port

  1. 查詢 http_port_t,8989 port 不是 httpd 程序允許訪問的 port。
    [root@kvm7 html]# semanage port -l | grep -w http_port
    http_port_t       tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
    
  2. 編輯 httpd 服務配置檔,將服務的訪問埠號改成 8989。
    [root@kvm7 html]# vim /etc/httpd/conf/httpd.conf
    [root@kvm7 html]# grep ^Listen /etc/httpd/conf/httpd.conf
    Listen 8989
    
  3. 無法重新啟動 httpd 服務。
    [root@kvm7 html]# systemctl restart httpd.service 
    Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
    
  4. 查看 httpd 服務狀態。
    [root@kvm7 html]# systemctl status httpd.service 
    httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
       Active: failed (Result: exit-code) since Thu 2019-10-17 07:23:04 CST; 15s ago
    ....
    Oct 17 07:23:04 kvm7.deyu.wang systemd[1]: Starting The Apache HTTP Server...
    Oct 17 07:23:04 kvm7.deyu.wang httpd[17917]: (13)Permission denied: AH00072:...9
    Oct 17 07:23:04 kvm7.deyu.wang httpd[17917]: (13)Permission denied: AH00072:...9
    
  5. 新增 8989 為 httpd 服務允許訪問的埠號。
    [root@kvm7 html]# semanage port -a -t http_port_t -p tcp 8989
    
  6. 再重新啟動 httpd 服務,成功啟動服務。
    [root@kvm7 html]# systemctl restart httpd.service
    
  7. 測試以 8989 埠號連線網頁,成功列出月曆。
    [root@kvm7 html]# curl http://127.0.0.1:8989/index.html
        October 2019    
    Su Mo Tu We Th Fr Sa
           1  2  3  4  5
     6  7  8  9 10 11 12
    13 14 15 16 17 18 19
    20 21 22 23 24 25 26
    27 28 29 30 31
    



De-Yu Wang 2020-05-14