centos7下执行firewall-cmd显示ImportError: No module named 'gi'

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

 

wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

 
阅读更多
posted @ 2019-05-08 11:19  洺剑残虹  阅读(2813)  评论(0编辑  收藏  举报