ToB企服应用市场:ToB评测及商务社交产业平台

标题: Linux 小本领:在 CentOS7 安装 XRDP 长途桌面服务器 [打印本页]

作者: 祗疼妳一个    时间: 2024-6-15 03:46
标题: Linux 小本领:在 CentOS7 安装 XRDP 长途桌面服务器
1)图形界面安装

   CentOS7 没有图形化操纵可能对很多人来说都不太风俗,下面我们来为 CentOS7 安装图形化界面,本文以安装 GNOME 图形化为例
  **写在安装前: **假如你的 CentOS7 是最小化安装,默认都是不带 XWINDOWS 的
  1. mkdir /etc/yum.repos.d/backup
  2. mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
  3. cat > /etc/yum.repos.d/base.repo <<EOF
  4. [base]
  5. name=base
  6. baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
  7.         https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
  8.         https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
  9.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
  10.         http://mirrors.163.com/centos/\$releasever/os/\$basearch/
  11.         http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
  12. gpgcheck=1
  13. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  14. [epel]
  15. name=epel
  16. baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
  17.         https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
  18.         https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
  19.         https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
  20. gpgcheck=1
  21. gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever
  22. [extras]
  23. name=extras
  24. baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
  25.         https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
  26.         https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
  27.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
  28.         http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
  29.         http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
  30. gpgcheck=1
  31. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  32. [updates]
  33. name=updates
  34. baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
  35.         https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
  36.         https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
  37.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
  38.         http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
  39.         http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
  40. gpgcheck=1
  41. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  42. [centosplus]
  43. name=centosplus
  44. baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
  45.         https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
  46.         https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
  47.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
  48.         http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
  49.         http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
  50. gpgcheck=1
  51. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  52. EOF
  53. yum clean all
  54. yum repolist
复制代码
输入安装 GNOME Desktop 命令
  1. // < '桌面二选一' >
  2. 1. yum groupinstall -y "GNOME Desktop"         # GNOME DESKTOP
  3. 2. yum groupinstall -y "MATE Desktop"                # MATE DESKTOP
复制代码

安装完毕后,必要 设置默认从图形化界面启动
  1. // 设置成图形模式
  2. systemctl set-default graphical.target  
复制代码
重启系统
  1. reboot
复制代码
2)VNC 服务安装

   Linux 系统在服务器上一样平常都直接最小化安装,并未安装图形界面,但是有时候,有一些特别情况,必要使用图形界面。< 当然,实在我们也可以直接通过 XServer 转发至 Windows 显示 >
下面我将使用 VNC 来实现类似 Windows 的长途桌面功能。
    首先,系统必要有图形界面,可以在安装系统的时候一起安装 GNOME,或者背面再安装也行,下面即安装方法。
  
  1. mkdir /etc/yum.repos.d/backup
  2. mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
  3. cat > /etc/yum.repos.d/base.repo <<EOF
  4. [base]
  5. name=base
  6. baseurl=https://mirrors.aliyun.com/centos/\$releasever/os/\$basearch/
  7.         https://mirrors.huaweicloud.com/centos/\$releasever/os/\$basearch/
  8.         https://mirrors.cloud.tencent.com/centos/\$releasever/os/\$basearch/
  9.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/os/\$basearch/
  10.         http://mirrors.163.com/centos/\$releasever/os/\$basearch/
  11.         http://mirrors.sohu.com/centos/\$releasever/os/\$basearch/
  12. gpgcheck=1
  13. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  14. [epel]
  15. name=epel
  16. baseurl=https://mirrors.aliyun.com/epel/\$releasever/\$basearch/
  17.         https://mirrors.huaweicloud.com/epel/\$releasever/\$basearch/
  18.         https://mirrors.cloud.tencent.com/epel/\$releasever/\$basearch/
  19.         https://mirrors.tuna.tsinghua.edu.cn/epel/\$releasever/\$basearch/
  20. gpgcheck=1
  21. gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-\$releasever
  22. [extras]
  23. name=extras
  24. baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/
  25.         https://mirrors.huaweicloud.com/centos/\$releasever/extras/\$basearch/
  26.         https://mirrors.cloud.tencent.com/centos/\$releasever/extras/\$basearch/
  27.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/
  28.         http://mirrors.163.com/centos/\$releasever/extras/\$basearch/
  29.         http://mirrors.sohu.com/centos/\$releasever/extras/\$basearch/
  30. gpgcheck=1
  31. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  32. [updates]
  33. name=updates
  34. baseurl=https://mirrors.aliyun.com/centos/\$releasever/updates/\$basearch/
  35.         https://mirrors.huaweicloud.com/centos/\$releasever/updates/\$basearch/
  36.         https://mirrors.cloud.tencent.com/centos/\$releasever/updates/\$basearch/
  37.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/updates/\$basearch/
  38.         http://mirrors.163.com/centos/\$releasever/updates/\$basearch/
  39.         http://mirrors.sohu.com/centos/\$releasever/updates/\$basearch/
  40. gpgcheck=1
  41. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  42. [centosplus]
  43. name=centosplus
  44. baseurl=https://mirrors.aliyun.com/centos/\$releasever/centosplus/\$basearch/
  45.         https://mirrors.huaweicloud.com/centos/\$releasever/centosplus/\$basearch/
  46.         https://mirrors.cloud.tencent.com/centos/\$releasever/centosplus/\$basearch/
  47.         https://mirrors.tuna.tsinghua.edu.cn/centos/\$releasever/centosplus/\$basearch/
  48.         http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/
  49.         http://mirrors.sohu.com/centos/\$releasever/centosplus/\$basearch/
  50. gpgcheck=1
  51. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-\$releasever
  52. EOF
  53. yum clean all
  54. yum repolist
复制代码
  1. // 列出的组软件包列表// < '桌面二选一' >yum grouplistyum groupinstall -y "GNOME Desktop"                        // 安装 GNOME DESKTOPyum groupinstall -y "MATE Desktop"                        // 安装 MATE Desktop# 安装完成后, 修改默认启动方式为图形化界面// 设置成图形模式
  2. systemctl set-default graphical.target  
  3. # 假如要换返来// 设置成命令模式systemctl set-default multi-user.target  
复制代码
  然后重启即可。
  
  1. yum install tigervnc-server -y
复制代码
  1. // 复制一个 Service 服务设置模板
  2. cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  3. // 修改此服务配置
  4. # 以下为 root 用户的配置, 每一个用户, 都需要单独设置一个监听服务, 且配置不同
  5. vim /etc/systemd/system/vncserver@\:1.service
  6. [Unit]
  7. Description=Remote desktop service (VNC)
  8. After=syslog.target network.target
  9. [Service]
  10. Type=forking
  11. User=root
  12. # Clean any existing files in /tmp/.X11-unix environment
  13. ExecStartPre=-/usr/bin/vncserver -kill %i
  14. ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
  15. PIDFile=/root/.vnc/%H%i.pid
  16. ExecStop=-/usr/bin/vncserver -kill %i
  17. [Install]
  18. WantedBy=multi-user.target
复制代码
  1. [root@localhost ~] vncpasswd
  2. Password:
  3. Verify:
  4. Would you like to enter a view-only password (y/n)? n                # 这里不添加只读账号密码
  5. A view-only password is not used
复制代码
  1. # 设为开机启动
  2. systemctl start vncserver@:1
  3. systemctl enable vncserver@:1
  4. # 查看服务监听的端口
  5. netstat -lnpt | grep Xvnc
  6. # 根据监听的端口
  7. # 进行端口开放
  8. # 每个用户会对应一个端口, 第一个用户默认为 5901 端口, 我这里是 root 用户
  9. firewall-cmd --add-port=5901/tcp --permanent
  10. firewall-cmd --reload
复制代码


**注意:MATE DESKTOP **桌面可能会出现如下状态

办理
  1. < '解决' >
  2. vim ~/.vnc/xstartup
  3. unset SESSION_MANAGER
  4. unset DBUS_SESSION_BUS_ADDRESS
  5. /usr/bin/mate-session &
复制代码

重启 ROOT 端口服务
  1. systemctl restart vncserver@:1
复制代码

   完成 VNC 连接~
  3)XRDP 服务安装

CentOS7 提供了 “Cinnamon Desktop”“MATE Desktop”“GNOME Desktop”“KDE Plasma Workspaces”“LXQt Desktop”,**“Xfce” ** 让我们安装。
  1. // < '桌面二选一' >
  2. yum groupinstall Xfce -y
  3. yum groupinstall "MATE Desktop" -y
复制代码
  1. yum -y install xrdp
复制代码
  1. systemctl start xrdp
  2. systemctl enable xrdp
  3. // 验证端口
  4. netstat -nltp | grep 3389
复制代码

  1. // xfce Desktop
  2. echo "xfce4-session" > ~/.Xclients
  3. chmod +x .Xclients
  4. // mate Desktop
  5. echo "mate-session" > ~/.Xclients
  6. chmod +x .Xclients
复制代码

输入 **Linux 系统 **的账户认证


   大功告成~

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4