赞
踩
CentOS7 没有图形化操作可能对很多人来说都不太习惯,下面我们来为 CentOS7 安装图形化界面,本文以安装 GNOME 图形化为例
**写在安装前: **如果你的 CentOS7 是最小化安装,默认都是不带 XWINDOWS 的
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
Linux 系统在服务器上一般都直接最小化安装,并未安装图形界面,但是有时候,有一些特殊情况,需要使用图形界面。< 当然,其实我们也可以直接通过 XServer 转发至 Windows 显示 >
下面我将利用 VNC 来实现类似 Windows 的远程桌面功能。
首先,系统需要有图形界面,可以在安装系统的时候一起安装 GNOME,或者后面再安装也行,下面即安装方法。
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
// 列出的组软件包列表
// < '桌面二选一' >
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
然后重启即可。
yum install tigervnc-server -y
// 复制一个 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
[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
**注意:MATE DESKTOP **桌面可能会出现如下状况
解决
< '解决' >
vim ~/.vnc/xstartup
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/usr/bin/mate-session &
重启 ROOT 端口服务
systemctl restart vncserver@:1
完成 VNC 连接~
CentOS7 提供了 “Cinnamon Desktop”,“MATE Desktop”,“GNOME Desktop”,“KDE Plasma Workspaces”,“LXQt Desktop”,**“Xfce” ** 让我们安装。
// < '桌面二选一' >
yum groupinstall Xfce -y
yum groupinstall "MATE Desktop" -y
yum -y install xrdp
systemctl start xrdp
systemctl enable xrdp
// 验证端口
netstat -nltp | grep 3389
// xfce Desktop
echo "xfce4-session" > ~/.Xclients
chmod +x .Xclients
// mate Desktop
echo "mate-session" > ~/.Xclients
chmod +x .Xclients
输入 **Linux 系统 **的账户认证
大功告成~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。