屯昌县救护车出租网

CentOS 7一键安装桌面环境命令(可远程RDP连接)

2026-03-25 09:45:01 浏览次数:0
详细信息

1. 一键安装脚本

#!/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"

2. 使用方法

将上述脚本保存为 install_desktop.sh,然后执行:

chmod +x install_desktop.sh
./install_desktop.sh

3. 重启系统

reboot

4. 连接说明

使用Windows自带的远程桌面连接(mstsc) 服务器地址:你的服务器IP:3389 用户名:root(或你创建的其他用户) 密码:服务器的root密码

5. 可选配置

创建新用户(推荐)

# 创建新用户
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

注意事项

安全警告:使用root远程登录存在安全风险,建议创建普通用户 内存要求:GNOME桌面至少需要2GB内存 网络带宽:RDP远程桌面需要稳定的网络连接 如果使用云服务器,还需要在云控制台安全组开放3389端口

轻量级桌面方案(如果服务器配置较低)

如果要安装更轻量的桌面环境,可以使用XFCE:

yum groupinstall "Xfce" -y
echo "startxfce4" > /etc/xrdp/startwm.sh

安装完成后,即可通过RDP客户端远程连接到CentOS 7的图形界面。

相关推荐