1)图形界面安装
CentOS7 没有图形化操作可能对很多人来说都不太习惯,下面我们来为 CentOS7 安装图形化界面,本文以安装 GNOME 图形化为例
**写在安装前: **如果你的 CentOS7 是最小化安装,默认都是不带 XWINDOWS 的
- 配置公网 Yum 源
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
http://mirrors.163.com/centos/\$releasever/os/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[updates]
name=updates
baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[centosplus]
name=centosplus
baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
EOF
yum clean all
yum repolist
输入安装 GNOME Desktop 命令
// < '桌面二选一' >
1. yum groupinstall -y "GNOME Desktop" # GNOME DESKTOP
2. yum groupinstall -y "MATE Desktop" # MATE DESKTOP
安装完毕后,需要 设置默认从图形化界面启动
// 设置成图形模式
systemctl set-default graphical.target
重启系统
reboot
2)VNC 服务安装
Linux 系统在服务器上一般都直接最小化安装,并未安装图形界面,但是有时候,有一些特殊情况,需要使用图形界面。< 当然,其实我们也可以直接通过 XServer 转发至 Windows 显示 >
下面我将利用 VNC 来实现类似 Windows 的远程桌面功能。
首先,系统需要有图形界面,可以在安装系统的时候一起安装 GNOME,或者后面再安装也行,下面即安装方法。
- 配置公网 Yum 源
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
http://mirrors.163.com/centos/\$releasever/os/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[updates]
name=updates
baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
[centosplus]
name=centosplus
baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
EOF
yum clean all
yum repolist
- 安装 GNOME 桌面
// 列出的组软件包列表
// < '桌面二选一' >
yum grouplist
yum groupinstall -y "GNOME Desktop" // 安装 GNOME DESKTOP
yum groupinstall -y "MATE Desktop" // 安装 MATE Desktop
# 安装完成后, 修改默认启动方式为图形化界面
// 设置成图形模式
systemctl set-default graphical.target
# 如果要换回来
// 设置成命令模式
systemctl set-default multi-user.target
然后重启即可。
- 安装 VNC SERVER
yum install tigervnc-server -y
- 将 root 用户的 VNC 端口 设置为 Service 服务
// 复制一个 Service 服务设置模板
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
// 修改此服务配置
# 以下为 root 用户的配置, 每一个用户, 都需要单独设置一个监听服务, 且配置不同
vim /etc/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
- 设置 VNC 密码,VNC 的密码跟系统的用户密码不一样,是使用 VNC 客户端登陆时需要使用的密码。
[root@localhost ~] vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n # 这里不添加只读账号密码
A view-only password is not used
- 启动服务,验证端口
# 设为开机启动
systemctl start vncserver@:1
systemctl enable vncserver@:1
# 查看服务监听的端口
netstat -lnpt | grep Xvnc
# 根据监听的端口
# 进行端口开放
# 每个用户会对应一个端口, 第一个用户默认为 5901 端口, 我这里是 root 用户
firewall-cmd --add-port=5901/tcp --permanent
firewall-cmd --reload
- 到此 VNC 服务就已经安装完成了。然后需要使用 VNC 客户端进行连接。
**注意:MATE DESKTOP **桌面可能会出现如下状况
解决
< '解决' >
vim ~/.vnc/xstartup
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/usr/bin/mate-session &
重启 ROOT 端口服务
systemctl restart vncserver@:1
完成 VNC 连接~
3)XRDP 服务安装
CentOS7 提供了 “Cinnamon Desktop”,“MATE Desktop”,“GNOME Desktop”,“KDE Plasma Workspaces”,“LXQt Desktop”,**“Xfce” ** 让我们安装。
- 我们可以选择自己喜欢的桌面环境,在这里选择安装 MATE DESKTOP 桌面:
// < '桌面二选一' >
yum groupinstall Xfce -y
yum groupinstall "MATE Desktop" -y
- 安装 XRDP
yum -y install xrdp
- 安装完成之后,设置开机默认启动 XRDP
systemctl start xrdp
systemctl enable xrdp
// 验证端口
netstat -nltp | grep 3389
- 创建 ~/.Xclients,设置默认启动 xfce4 桌面
// xfce Desktop
echo "xfce4-session" > ~/.Xclients
chmod +x .Xclients
// mate Desktop
echo "mate-session" > ~/.Xclients
chmod +x .Xclients
- 在 Windows 客户端远程连接
输入 **Linux 系统 **的账户认证
文章来源:https://www.toymoban.com/news/detail-797431.html
大功告成~文章来源地址https://www.toymoban.com/news/detail-797431.html
到了这里,关于如何在CentOS7 安装 XRDP 远程桌面服务器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!