找回密码
 注册
查看: 30|回复: 1

centos9 stream 安装vncserver

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-23 17:03:30 | 显示全部楼层 |阅读模式
centos9 stream 安装vncserver9 l4 H+ [& A7 X4 E1 p7 {& R" }0 r
- J- }5 {  Y' G$ S! n
" K/ s/ T1 G/ }) d0 O; W
1 y0 r; ^  a' u6 W5 T7 a

5 n) @- d: \) @  N8 T3 u yum install -y xdpyinfo1 C" @" d  K# W  ?0 s

% d, {: l" p# Z8 \2 |$ Z, U: b+ t; K5 \- P3 _  j: r8 s3 s
+ e5 ?! o9 }. u+ Z
yum install -y tigervnc tigervnc-server
% a8 B( z+ n) E' S4 v7 G1 g5 }4 ]# k8 r! A+ h# w) @1 J, Q
% u6 S* H- ~* w+ T9 }
" R$ S5 w8 h* w9 A7 D
vncserver
/ b' X5 W0 \& b' ^2 d8 C, q  C  ^9 f- k) q& P( y# a  X( m; q8 a
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream./ Q7 s& i% H9 Y
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.4 j: p( G3 \5 L& E( |

9 \( J: m. r3 h. `Warning: python-flask:1 is taken because of /tmp/.X1-lock
. A* P5 M) `5 O8 o! ^: l1 U! |) [! m) X* KRemove this file if there is no X server python-flask:1: }  W8 H- @. X6 O# O, ~, I

5 e" b) d8 D; q  G! p/ GYou will require a password to access your desktops.
! n( b+ M: B  Y! U& o6 H8 q$ Y) D; T% @
Password:5 W) K, C( W! h+ P* A
Verify:# L/ W- @  q( t: i0 `9 z
Would you like to enter a view-only password (y/n)? y
7 p0 O2 z, f8 g: X, F, x+ z0 gPassword:/ b% ?& Q0 G: h! C% H: Y% M
Verify:
: J: t, {) l$ C0 [8 \3 B
9 L& v2 @, y' P8 QNew 'python-flask:2 (root)' desktop is python-flask:2
4 o$ [6 }8 f2 t2 H! ~: V5 P- s( k
Creating default startup script /root/.vnc/xstartup
9 i! e# E; S1 V6 u- bCreating default config /root/.vnc/config) t% V- [0 Z& Y0 `$ G) \$ T8 I  Y
Starting applications specified in /root/.vnc/xstartup
; o2 E0 o; T* L6 a/ eLog file is /root/.vnc/python-flask:2.log! C- L" X+ _% n2 a/ g4 b5 }
! q8 |9 \" M& U1 H: l/ _
修改vncserver.users文件

使用如下的命令修改文件

9 U3 @' E3 S) x5 J! a
vim /etc/tigervnc/vncserver.users* x7 d, {7 D0 {! H) I
% f7 i2 R3 X. ?- f8 c1 e6 t3 O3 J

9 ]* ^2 D- U4 a# @/ I6 Z+ S# TigerVNC User assignment+ N5 l8 J: v/ j- I( U4 J
#
! q1 a5 `$ X; {1 R: s) }& U# X6 B# This file assigns users to specific VNC display numbers.
' q# B: e- B: l& @3 J# The syntax is <display>=<username>. E.g.:" S! X/ m6 j8 A( ?* Z
#$ s2 g( `7 p4 z( v, }$ h
# :2=andrew
9 ~  u; c, `# d$ x# :3=lisa
$ U0 O/ k# W. X  ?7 u% h:1=root
" R3 r7 }2 {( t:2=devops
( I7 B- P8 P" F, I. \  h/ f# ~2 r
% G3 j! |! S4 U" E- F8 H/ K) Q5 N! d3 l
修改vncserver-config-defaults

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-defaults

session=gnome

securitytypes=vncauth,tlsvnc

desktop=sandbox

geometry=2000x1200

) G# ^% l0 L3 @* T: B

alwaysshared

* x' ]2 q0 U" X4 e+ {- x
其中localhost需要注释掉,否则将不能进行外部访问
3 U& Q* h$ w, v6 ~, {8 U2 z: Z  X0 I

* W5 e: X( H# z
$ E1 r5 n# [' f3 g% e! Q修改vncserver-config-mandatory

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-mandatory

geometry=2000x1200

securitytypes=vncauth,tlsvnc

desktop=sandbox

#geometry=2000x1200

  t/ C7 t+ z) s2 K* \& U; J

alwaysshared

同理,需要将localhost注释

修改config

使用如下的命令修改文件

vim $HOME/.vnc/config

session=gnome

geometry=1000x1200


2 O& M/ F1 G' h- q$ F7 J- f
! `# [4 L, T# R. Z/ o" `( w# r复制vncserver@x.service
  ]2 Q0 H( \% I7 lcp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
9 t+ C  F$ L# z6 I- p2 F* d  z7 w4 T& j: @% N, O* t
  C0 \- s  ]' C. }! b2 W# O

3 `9 D1 l7 j; y' b) i- ~1 ^
6 p( ?- t. |0 s1 V4 i5 A6 B/ Avncpasswd
$ A4 S% K0 G4 `; e+ Z" C0 r5 GPassword:) ^1 l2 c) _9 k: J9 m# V% h; I0 C& x) S
Verify:
3 I. O* @- C  @8 b) ^Would you like to enter a view-only password (y/n)? n- ]  e. n7 ?6 S+ q
A view-only password is not used$ w. q8 c! ?1 h2 r7 ?3 |' N
3 @, p. H/ o5 E6 q& z# ~% M
# U0 l3 X% H: W4 l

; ~8 V$ y$ A5 |7 d! J: v3 B1 z0 `  U5 [
[root@python-flask ~]# systemctl restart vncserver@:1
  J) p7 p6 x( l# X/ L+ |# k. c1 g[root@python-flask ~]# systemctl status vncserver@:1$ R' H8 c$ V4 i. H
○ vncserver@:1.service - Remote desktop service (VNC)
6 M% @8 Z5 L7 l4 m4 K. z     Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)( \! O, z0 z( `5 T' R+ z
     Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago  f! ~, t- @/ s  A9 z4 w4 o
   Duration: 17ms3 s+ b% _2 b) d0 |9 [( i  \4 n
    Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)' @8 e' y) A+ Y/ _1 P. F
    Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
$ @+ T4 C5 A* V) P2 J, h2 f   Main PID: 5221 (code=exited, status=0/SUCCESS)
8 x7 [5 T0 r- L. j5 G7 J        CPU: 23ms1 Z6 ^; M9 A, i4 u" {

! A! R1 G2 r- ?2 S' `0 i: i7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)...
- \9 P) @+ T' {7 k; B2 p& `7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).& |/ g* k5 O2 i* q  x# x
7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.$ }8 o2 q; ]1 @5 b- Y
3 z9 E6 d5 D0 m1 u* E' L4 I* i. s
. r/ H$ o0 v( h; Y* l" P2 p' Y

) G* y3 c- {3 W  }" k+ V+ F; u至此vncserver安装完成。
& R, e, x& ~# v1 \

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-23 17:25:59 | 显示全部楼层
[root@python-flask ~]# firewall-cmd --add-port=5900-6000/tcp --permanent8 n' G% Y3 v- |5 ]8 }+ ^1 Y/ V# s
success
: B$ `+ R3 R" D) U0 C[root@python-flask ~]# firewall-cmd --reload $ K: l/ B/ h6 v/ j! F, d8 u8 O- h- v
success
. [4 U8 v) S3 Q/ M5 A. x* d0 I
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:20 , Processed in 0.017179 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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