2022年9月12日 星期一

【IT Notes】RHCSA考題:SELinux與防火牆修改

 這題算是簡單好解的題目,記錄的目的主要是怎麼安裝可是環境,讓要練習的時候可以直接開始,所以就紀錄一下,以便今後還有需要的時候省點力。

ㄧ.設定考題環境

[root@node1 ~]# getenforce

Enforcing

[root@node1 ~]# yum -y install httpd

[root@node1 ~]# vim /etc/httpd/conf/httpd.conf 

Listen 82

[root@node1 ~]# echo "test page" > /var/www/html/index.html

[root@node1 ~]# systemctl enable --now httpd   

[root@node1 ~]# systemctl status httpd       

   

二.解題方式

[root@node1 ~]# systemctl restart httpd  \\啟用網頁伺服器,發現出錯
Job for httpd.service failed because the control process exited with e
rror code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@node1 ~]# semanage port -a -t http_port_t -p tcp 82 \\添加selinux的82 port
[root@node1 ~]# semanage port -l | grep http
[root@node1 ~]# systemctl start httpd 
[root@node1 ~]# systemctl status httpd 
[root@node1 ~]# systemctl enable httpd --now  \\開機時啟動網頁伺服器
[root@node1 ~]# firewall-cmd --add-port=82/tcp --permanent \\防火牆添加 82 port
success
[root@node1 ~]# firewall-cmd --reload  
success
[root@node1 ~]# curl node1:82 \\驗證網頁
test page

或者是開firefox,輸入網址http:node1:82看看結果,有顯示出來的話就是成功了。

沒有留言:

張貼留言

【少年回憶】尋夢谷

 「尋夢谷」這個地名,在我人生中是一個很深刻的存在。那大約是國中二年級的事情了吧,距離現在快要三十年了。後來重新找到這個地方的時候,這裡只剩下大門和一處房舍,尤其是後者,讓我一看到馬上就能辨識出來;至於剩下的其他地方,如今只剩下一片荒煙蔓草、汽車駕訓班和工寮。 為什麼此處留有我那...