# ucloud环境开启selinux

## 问题描述

ucloud 能centos7.6 镜像创建主机默认不开启selinux, 按常规方法配置，开启selinux后，主机ping 不能，web console 也不能正常登录

/etc/selinux/config文件

```
SELINUX=permissive
SELINUXTYPE=targeted
```

## 解决方法

### 1.新建主机后 修改/etc/selinux/config文件，selinux设置为 permissive (宽容模式)

```
SELINUX=permissive
SELINUXTYPE=targeted
```

### 2.重启虚机

```
reboot
```

### 3.使用以下命令reset权限位

```
restorecon -R -v /
```

### 4.再次重启虚机

```
reboot
```

### 5.selinux 改为 enforcing (强制模式)

修改/etc/selinux/config文件,

```
SELINUX=enforcing
```

### 6.再次重启虚机

```
reboot
```

### 7. 现在已经是正常开始了selinux, 并且所有功能正常，此状态下的主机镜像可以制作为 自制镜像，以后使用自制镜像创建主机，默认就是开启selinux状态了。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liujinye.gitbook.io/openshift-docs/troubleshooting/ucloud-huan-jing-kai-qi-selinux-dao-zhi-wang-luo-bu-tong-wen-ti.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
