ToB企服应用市场:ToB评测及商务社交产业平台
标题:
Linux 小本领:在 CentOS7 安装 XRDP 长途桌面服务器
[打印本页]
作者:
祗疼妳一个
时间:
2024-6-15 03:46
标题:
Linux 小本领:在 CentOS7 安装 XRDP 长途桌面服务器
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 grouplistyum groupinstall -y "GNOME Desktop" // 安装 GNOME DESKTOPyum 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 系统 **的账户认证
大功告成~
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4