centos7 安裝tomcat 及問題處理(No module named 'gi')(Job for firewalld.service failed because the control)
安裝tomcat需要安裝jdk: centos7 安裝jdk 及 配置環境變量 傳送門
1、下載tomcat:
最新版本:
https://tomcat.apache.org/download-80.cgi
2、上傳到安裝目錄(xftp)
3、解壓所下載的壓縮包
tar zxfv apache-tomcat-8.*.**.tar.gz
4、開發8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
錯誤信息:
[root@hyl bin]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
Traceback (most recent call last):
File "/usr/bin/firewall-cmd", line 24, in <module>
from gi.repository import GObject
ModuleNotFoundError: No module named 'gi'
vi /usr/bin/firewall-cmd
第一行更改為之前python版本
#!/usr/bin/python2.7 -Es
開啟防火牆
systemctl start firewalld
錯誤信息
Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details
查看信息:
systemctl status firewalld.service
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since 三 2019-02-20 13:06:15 CST; 1min 11s ago
Docs: man:firewalld(1)
Process: 6195 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=203/EXEC)
Main PID: 6195 (code=exited, status=203/EXEC)
vi /usr/sbin/firewalld
同樣修改 第一行 #!/usr/bin/python2.7 -Es
再次啟動防護牆:(不顯示其他信息 為正常信息)
systemctl status firewalld
開啟8080端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
提示:success
更新防火牆規則
firewall-cmd --reload
查看端口開放狀態:
firewall-cmd --zone=public --query-port=8080/tcp
再次通過ip端口訪問,出現tomcat默認頁面。
查看所有打開的端口: firewall-cmd --zone=public --list-ports
刪除端口:firewall-cmd --zone=public --remove-port=80/tcp --permanent
更新防火牆規則: firewall-cmd --reload