#!/bin/bash
# CentOS 7 GNOME Desktop + RDP一键安装脚本
# 更新系统
yum update -y
# 安装GNOME桌面
yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y
# 安装Xrdp(RDP服务器)
yum install epel-release -y
yum install xrdp tigervnc-server -y
# 配置Xrdp
echo "startwm.sh" > /etc/xrdp/startwm.sh
chmod +x /etc/xrdp/startwm.sh
# 启用服务
systemctl enable xrdp
systemctl start xrdp
systemctl set-default graphical.target
# 开放防火墙端口
firewall-cmd --permanent --add-port=3389/tcp
firewall-cmd --reload
# 设置自动登录(可选)
echo "[daemon]" > /etc/gdm/custom.conf
echo "AutomaticLoginEnable=true" >> /etc/gdm/custom.conf
echo "AutomaticLogin=root" >> /etc/gdm/custom.conf
echo "安装完成!请重启系统: reboot"
echo "RDP连接地址: 服务器IP:3389"
将上述脚本保存为 install_desktop.sh,然后执行:
chmod +x install_desktop.sh
./install_desktop.sh
reboot
你的服务器IP:3389
用户名:root(或你创建的其他用户)
密码:服务器的root密码
# 创建新用户
adduser username
passwd username
# 将用户加入sudoers
usermod -aG wheel username
yum groupinstall "Chinese Support" -y
localectl set-locale LANG=zh_CN.UTF-8
yum install firefox libreoffice vim -y
如果要安装更轻量的桌面环境,可以使用XFCE:
yum groupinstall "Xfce" -y
echo "startxfce4" > /etc/xrdp/startwm.sh
安装完成后,即可通过RDP客户端远程连接到CentOS 7的图形界面。