標籤:
最近學習CentOS 7 系統管理,使用的是《CentOS 6.X系統管理實戰寶典》一書------因為網購的CentOS 7 的書還沒有送到 O(‘ ’!!)O~
(1)先使用yum方法安裝Webmin:
預設使用yum時無法安裝Webmin,原因是該軟體沒有在官方網站存放。雖然以前要用tar方式安裝,但是之後編譯出了RPM安裝包,所以只好自行配置更新網站。在/etc/yum.repo.d中建立webmin.repo檔案,編輯完成後儲存退出,然後匯入Webmin開放原始碼的GPG的數位簽章:
[[email protected] /]# vi /etc/yum.repos.d/webmin.repo[Webmin]name=Webmin Distribution Neutralbaseurl=http://download.webmin.com/download/yum //配置webmin安裝來來源站點點enabled=1[[email protected] /]# rpm --import http://www.webmin.com/jcameron-key.asc
然後使用yum方式進行安裝,
[[email protected] /]# yum install webmin
(2)安裝Apache軟體:
[[email protected] ~]# yum install httpd -y
(3)想要安裝Webmin系統管理工具,需要重新設定防火牆,Webmin預設使用的連接埠為10000,按照書上的教程設定了 /etc/sysconfig/iptables檔案:
[[email protected] /]# vi /etc/sysconfig/iptables#Firewall configuration written by system-config-firewall#Manual customization of this file is not recommanded.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m udp -p tcp --dport 10000 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT
按照書上的教程執行 service iptables restart 命令,卻失敗了,以為是CentOS 6.X的命令和 CentOS 7 的命令不相容的問題,網上搜CentOS 7啟動防火牆的方法,找到這個網頁:
CentOS7下Firewall防火牆配置用法詳解
按照如所示地區的Instruction,進行配置:
----------------------------------------以下為圖片---------------------------------------------
-----------------------------------------以上為圖片----------------------------------------------
(i) yum install iptables-services ,沒有問題
(ii) systemctl mask firewalld.service ,沒有問題
(iii) systemctl enable iptables.servie , 沒問題
為了提高網速,我禁用了ipv6,所以沒有執行 systemctl start ip6tables.service
(iv) systemctl stop firewalld.service , 沒問題
(v) systemctl start iptables.service ------ 有問題!
使用 cat /var/log/messages | grep iptables 命令查看相關錯誤:
由 Applying firewall rules: iptables-restore:line 2 failed 得知是 iptables 檔案的第二行由錯,於是 cat /etc/sysconfig/iptables:
一看,原來是 Manual configuration of this file is not recommended. 那句話沒有在前面加上#號注釋掉!
遂注釋之~
再次 systemctl start iptables.service,結果:
說是upd match: only valid for protocol 17
最終從這個網頁得到提示:http://stackoverflow.com/questions/25144598/failed-to-apply-firewall-rules-with-iptables-restore
輸入 iptables-restore < /etc/sysconfig/iptables:
顯示第14行有問題,但跟那個StackFlow網站的朋友的問題一樣,我的第14行是 COMMIT:
而他修改的方式是把 -p udp -m tcp 改為 -p udp -m udp, 而我檢查我按照書上的Instruction寫的iptables,也有這麼一行 -m udp -p tcp ,應該是不匹配的問題。想到Webmin要用瀏覽器管理伺服器,用的應該是tcp協議,於是將之改為 -m tcp -p tcp:
再輸入 systemctl start iptables.service, 沒問題。
輸入 service httpd restart 命令重啟 Apache 伺服器, 瀏覽器登入Webmin管理器:
可以看到登入介面了,說明iptables配置成功!
CentOS 7 下 安裝Webmin 啟動防火牆失敗----Applying firewall rules:iptables-restore:line 2 failed