易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 17|回复: 1
收起左侧

centos9 stream 安装vncserver

[复制链接]
发表于 2024-7-23 17:03:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
centos9 stream 安装vncserver7 y( L# j2 x. R# U5 `+ j" `
$ C+ W7 F+ _: s0 i* \
/ W& t" {' w" H7 Y0 b  |

9 K  A; e* r/ b5 I& I; D# K: U* e4 a8 [$ N- O  b7 z4 j$ j1 F
yum install -y xdpyinfo
- Q- d3 s6 e1 U. B  L9 ?/ f+ S+ R; j5 u* I

" k, U! N  E" W7 l# [0 _% {- I% ]6 H; @! Y+ R, d
yum install -y tigervnc tigervnc-server
) D$ Z" H/ H2 ]: O/ f) B& H( k; N
9 ]1 R) L$ k, C/ e' F' w- S
8 u3 }2 Z2 R5 R0 s
vncserver : R) K4 ?# M! N; i: p
( L9 z( f" M+ C0 p: G
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.. o- k  u7 |+ s9 d3 T% A. p& {/ D
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.) b8 o  m( m' p, z: E  Q
" c5 d8 h# P5 y& A
Warning: python-flask:1 is taken because of /tmp/.X1-lock
/ L. E* Z- [" |$ X* x' E# E+ V9 hRemove this file if there is no X server python-flask:1# {  k- h7 g5 A$ A- z8 G

  r: `$ r) t( R. _' B4 M; MYou will require a password to access your desktops.7 f" M" E& ~! k4 X9 ~
9 ?7 W5 P3 f8 ^
Password:- C1 J6 y- U+ F5 d6 v
Verify:: G3 v, y  v4 i  K- U% Z
Would you like to enter a view-only password (y/n)? y
4 }" _6 |" @7 U, r2 V6 w0 @# h. ^8 ]9 fPassword:5 b+ T& U/ E/ T* y
Verify:
7 a$ J, @+ g, c/ g2 A
! [7 Q: O8 U. b6 aNew 'python-flask:2 (root)' desktop is python-flask:2
$ i: ~, e+ k* R5 Y, h0 f% O1 S* e
Creating default startup script /root/.vnc/xstartup
1 u3 W2 [3 ]+ A' c; w2 B$ u: tCreating default config /root/.vnc/config/ q6 l) ~8 S7 d" w) S
Starting applications specified in /root/.vnc/xstartup- n, S* h4 a5 ^: e
Log file is /root/.vnc/python-flask:2.log* S$ f0 y  ^0 r0 Z3 O
- |8 t  o% u: P# Y" d
修改vncserver.users文件

使用如下的命令修改文件


2 q/ [1 ]; K4 ^1 x: j+ `vim /etc/tigervnc/vncserver.users
- k. s8 ~) l, }, l  Y" m( J/ [6 `9 O/ y0 m- N! o

/ x& D4 `1 U$ m0 K, c1 J# TigerVNC User assignment
1 ^5 }/ O7 w2 g& v6 q#: i# n" f# b/ z0 J3 h
# This file assigns users to specific VNC display numbers.
* g* K7 \( g8 [# |! f: g7 w% a0 t! P# The syntax is <display>=<username>. E.g.:; w7 h- l+ ?' R+ y% R& d) E! H2 i! S
## k8 U$ h' Y+ _% k  U
# :2=andrew# {2 V4 G2 c0 K3 ~; @6 }3 t
# :3=lisa. q/ L0 y6 H* w7 ~: N; N& I
:1=root
7 L) N! M, G2 t:2=devops
2 _  A5 R1 M' H5 a5 N& }
  f- C, q0 Y0 J% X! q4 b6 j. H" I
修改vncserver-config-defaults

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-defaults

session=gnome

securitytypes=vncauth,tlsvnc

desktop=sandbox

geometry=2000x1200

7 d- K2 S! c0 E. _. M

alwaysshared


' w7 u) n" D' O8 B9 r其中localhost需要注释掉,否则将不能进行外部访问1 d/ Z: g4 Y0 Z) Z. ^9 K  P9 W, d- g

2 p# t* m) z# i( \. m

  H) H6 K* O- V4 H/ {! A" Z5 Q3 N2 q5 Z7 [. L
修改vncserver-config-mandatory

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-mandatory

geometry=2000x1200

securitytypes=vncauth,tlsvnc

desktop=sandbox

#geometry=2000x1200


: l/ b0 W& g+ K2 U6 I" h7 D& |& P

alwaysshared

同理,需要将localhost注释

修改config

使用如下的命令修改文件

vim $HOME/.vnc/config

session=gnome

geometry=1000x1200

6 ?+ u9 s; s& a9 k: w+ f* `3 D/ B' \
$ t. v, r# r' B% t: l* h& }1 @( X
复制vncserver@x.service
/ [7 Z# l+ A+ ^& i+ S: Qcp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
$ D, e0 [, c& a+ L( Z8 D& s2 X6 O1 s+ h, H6 F
* k$ K. K! P# H, O4 L4 [9 ]4 c2 P
  [$ \) H) m6 @# W9 z; d- b' r
+ h9 B1 B* x5 ~9 n" b' c
vncpasswd
4 c& l; }2 v+ m  A% [Password:; Z& l. n! F( E4 F- D% p* N0 _5 D' j
Verify:  q" O) Y: ~$ c4 ?2 b4 M4 Y
Would you like to enter a view-only password (y/n)? n
2 u7 k! V6 D, W5 D1 j/ q3 oA view-only password is not used
" w$ Y. h0 b* n, ^) l' L  ]' [8 c
9 P3 H3 K( X0 L% ^& i: k- S) z

; _0 C) e$ d; G. t: l: r3 J0 n4 o3 b1 s2 I, J6 w) ~- t% c4 P
[root@python-flask ~]# systemctl restart vncserver@:15 y4 A; J0 ^" G
[root@python-flask ~]# systemctl status vncserver@:14 z  B+ E4 [  M; X
○ vncserver@:1.service - Remote desktop service (VNC)
& _. ]$ o  |* ~. y5 F     Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)
( `. k, y& t- w6 m     Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago; [* h  `# c3 L5 Z4 P* r6 R& ~
   Duration: 17ms
6 W; I1 O7 Z1 F+ {' y" L) S) t    Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)
3 r3 C4 H) ]+ A2 ]    Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
% E( n6 W- f1 Y, h1 j   Main PID: 5221 (code=exited, status=0/SUCCESS)
0 n" Y2 i% m( \' b) Z- F* p        CPU: 23ms4 h* |) [; @! u( O
2 t1 h! Q, M  n/ j/ y4 D4 Q
7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)...
' @$ a: m  A# ^. U7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).
8 k, {: e7 z- x4 x; h6 z5 L. }7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.
5 \3 {7 o  Y( N$ i- w' ~' p5 p1 `- I3 N* |- ?  c8 E, X
4 d0 d$ z, e  j9 K2 Y
8 C7 z7 P; }( t: u; G
至此vncserver安装完成。
; p% G5 W* m- v3 r
 楼主| 发表于 2024-7-23 17:25:59 | 显示全部楼层
[root@python-flask ~]# firewall-cmd --add-port=5900-6000/tcp --permanent& R7 |1 Y  O# {) T5 p" U2 H& D
success
( R% n' e: }# `& {[root@python-flask ~]# firewall-cmd --reload
1 [% Y( U# m5 u5 k, N" J4 Lsuccess
* @8 E  z  o/ b: F# Y/ \
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:26 , Processed in 0.041644 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表