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看看結果,有顯示出來的話就是成功了。

沒有留言:

張貼留言

【當兵回憶】八里連

 在我心目中新兵日記是天花板等級的軍教片,並不是說沒有比它更好的作品,只是因為它的在拍攝的背景和時間,也正是我在服兵役的同時,老婆很多次好奇問我,為什麼我總是放在YouTube的新兵日記直播,我都說我只放在有個聲音在,我沒有真正在看,但這行為仔細想想也好多年了吧!台詞聽到我都會背...