300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux禁止开机启动服务器 如何关闭SELinux并设置开机不启动

linux禁止开机启动服务器 如何关闭SELinux并设置开机不启动

时间:2023-12-22 21:17:16

相关推荐

linux禁止开机启动服务器 如何关闭SELinux并设置开机不启动

在安装软件的过程中,经常遇到修改常用工具的默认端口时,会经常启动失败,失败原因是SELinux限制了修改默认端口,导致启动服务时,抛出了异常。

[root@bigdata2 var]# systemctl status httpd

● httpd.service - The Apache HTTP Server

Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)

Active: failed (Result: exit-code) since Wed -04-04 09:48:22 CST; 12s ago

Docs: man:httpd(8)

man:apachectl(8)

Process: 24040 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)

Process: 24038 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)

Main PID: 24038 (code=exited, status=1/FAILURE)

Apr 04 09:48:22 bigdata2 httpd[24038]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:9104

Apr 04 09:48:22 bigdata2 httpd[24038]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:9104

Apr 04 09:48:22 bigdata2 httpd[24038]: no listening sockets available, shutting down

Apr 04 09:48:22 bigdata2 httpd[24038]: AH00015: Unable to open logs

Apr 04 09:48:22 bigdata2 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE

Apr 04 09:48:22 bigdata2 kill[24040]: kill: cannot find process ""

Apr 04 09:48:22 bigdata2 systemd[1]: httpd.service: control process exited, code=exited status=1

Apr 04 09:48:22 bigdata2 systemd[1]: Failed to start The Apache HTTP Server.

Apr 04 09:48:22 bigdata2 systemd[1]: Unit httpd.service entered failed state.

Apr 04 09:48:22 bigdata2 systemd[1]: httpd.service failed.

通过服务的状态,可以看出服务没权限去绑定我们设置的端口。

即时解决不重启服务器的方式如下:

[root@bigdata2 var]# setenforce 0

永久生效设置如下,编辑/etc/selinux/config 的配置文件:

[root@bigdata2 var]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

#SELINUX=enforcing

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

# targeted - Targeted processes are protected,

# minimum - Modification of targeted policy. Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

~

"/etc/selinux/config" 15L, 565C

将SELINUX的值设置为:disabled

退出保存,下次重启服务器,SELinux就不会开机启用。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。