CentOS安装桌面
yum -y groups install "GNOME Desktop"
startx
安装XRDP
yum -y install xrdp tigervnc-server
systemctl start xrdp.service
systemctl enable xrdp.service
安装 tigervnc
yum install tigervnc tigervnc-server
vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? y
Password:
Verify:
New 'kylin:2 (root)' desktop is kylin:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/kylin:2.log
重新设置密码
输入一下命令
cd /root/.vnc/
rm -rf passwd
输入 vncserver
重新设置密码
#重启
1、杀掉vnc进程
2、删掉/tmp/目录下.X11-unix、.X1-lock这两个文件
3、再删掉/root/.vnc目录 然后重新执行vnserver启动vnc服务看看
4、配置有效启动桌面
vi /etc/sysconfig/vncservers
配置vncserver自启动
chkconfig vncserver on
如何使vncserver在每次启动时保持不变的端口号(5901)
设置VNCserver启动变量:
为了使VNCserver在每次启动时保持不变的端口号(5901)
在/etc/rc.d/rc.local文件中添加命令:
rm -f /tmp/.X11-unix/X*
rm -f /.VNC/*.pid
rm -f /.VNC/*.log
这样,每次启机,系统会先把上次非正常关机时留下的临时文件删除。
安装noVNC
下载noVNC
https://codeload.github.com/novnc/noVNC/zip/refs/heads/master
下载websockify
https://github.com/novnc/websockify/tree/master/websockify
https://codeload.github.com/novnc/websockify/zip/refs/heads/master
指定文件解压位置
unzip noVNC-master.zip -d /usr/local
unzip websockify-master.zip -d /usr/local/noVNC-master/utils
mv /usr/local/noVNC-master/utils/websockify-master /usr/local/noVNC-master/utils/websockify
配置noVNC
生成self.pem文件放到noVNC/utils底下(原因:VNC的默认会话不是安全的,我们需要创建一个安全的VNC连接,一路回车就好)
cd /usr/local/noVNC-master/utils
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
如果提示缺少python3请安装
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum -y install epel-release
yum install python-pip
pip install wget
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
xz -d Python-3.6.8.tar.xz
tar -xf Python-3.6.8.tar
cd Python-3.6.8
./configure prefix=/usr/local/python3
make && make install
yum install zlib zlib
yum install zlib zlib-devel
yum install -y python3-pip
python3 -V
启动服务
启动vnc服务
vncserver
/usr/local/noVNC-master/utils/novnc_proxy --vnc localhost:5901
主机的浏览器访问服务器(http://服务器ip:6080/vnc.html)