LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: baojian2002125

老总要我完成的一个小任务,我三周了还没搞定!神阿救救我。

[复制链接]
发表于 2007-5-21 10:39:31 | 显示全部楼层
用vncserver服务和用vncserver命令是不一样的
如果用service,启动的是/etc/sysconfig/vncservers里配置的用户
而命令行启动的是当前用户
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-22 11:44:50 | 显示全部楼层
Post by geoffrey001
要把/etc/X11/下的一个文件拷成~/.vnc/xstartup,网上可以很容易搜到,debian上是xinit/xinitrc
兄台的意思将.vnc/xstartup复制到 /etc/X11下,是么?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-22 11:54:37 | 显示全部楼层
我用的是5901端口。并且以普通用户身份运行vncserver
[allen@local ~]$ vncserver

New 'local:1 (allen)' desktop is local:1

Starting applications specified in /home/allen/.vnc/xstartup
Log file is /home/allen/.vnc/local:1.log
立即去查看local:1.log内容:
Tue May 22 09:42:35 2007
vncext:      VNC extension running!
vncext:      Listening for VNC connections on port 5901
vncext:      Listening for HTTP connections on port 5801
vncext:      created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

Fatal server error:
could not open default font 'fixed'
xsetroot:  unable to open display 'local:1'
vncconfig: unable to open display "local:1"

(gnome-session:15494): Gtk-WARNING **: cannot open display:
去用viewer连接,(192.168.1.100:5901),还是Connection Refused ,连接不上。
注:我的.vnc/xstartup的配置内容是:
[allen@local .vnc]$ vi xstartup

#!/bin/sh

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
(遵照某个兄弟的建议,改为启动gnome界面。但我还不知道我目前的图形界面是gnome还是kde,如何判别呢?:(。)
回复 支持 反对

使用道具 举报

发表于 2007-5-22 14:14:45 | 显示全部楼层
应该是~/.xstartup,linux里很少有~/.xxx/.yyyy这种配置文件的
回复 支持 反对

使用道具 举报

发表于 2007-5-22 14:41:52 | 显示全部楼层
Post by cobranail
应该是~/.xstartup,linux里很少有~/.xxx/.yyyy这种配置文件的

是~/.vnc/xstartup
不是你说的~/.xxx/.yyyy
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-22 15:39:16 | 显示全部楼层
到底怎么办呢?
回复 支持 反对

使用道具 举报

发表于 2007-5-22 15:59:09 | 显示全部楼层
按下面的步骤进行操作:
1.第一次启动的时候
#vncserver 会让你输入登录的密码
如果是已经启动过,不会提示输入密码。
2,会生成/root/.vnc/xstartup文件,你把最后一行注释掉,然后添加
startkde &
或者
gnome-session &


例如:
#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startkde &

3,然后重启服务:#vncserver -kill :1 关闭
  #vncserver 启动

4,然后通过vncviewer进行登录,注意登录的用户应该是你操作的用户
#vncviewer ip:1

如果按上面的操作有问题的话,请贴上错误的原因,好分析
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-22 17:12:37 | 显示全部楼层

回复Keven :)Thanks!

(声明:我的Linux没有显示器,所以以下内容都是我在Windows上通过SSH远程操作的,不过效果和亲自在Linux上命令界面操作一样)
一、因为有的兄弟说root用户受限制,我用普通用户(allen)身分运行vncserver:
[allen@local ~]$ vncserver

New 'local:1 (allen)' desktop is local:1

Starting applications specified in /home/allen/.vnc/xstartup
Log file is /home/allen/.vnc/local:1.log

[allen@local ~]$ cd /root/.vnc
-bash: cd: /root/.vnc: 权限不够
[allen@local ~]$
至此,我无法进入/root/.vnc/xstartup文件,所以改换为root用户登陆:  (真球默即,呵呵。费这事干嘛!)
二、以root身分操作vncserver:
1、[root@local ~]# vncserver

New 'local:1 (root)' desktop is local:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/local:1.log

[root@local ~]#

注意:我极少遇到要我输入密码的,除非是重装了vncserver或者更换用户。[这世道,什么事都能遇上]
2、 现在我察看/root/.vnc/xstartup文件内容如下:
[root@local ~]# vi /root/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 1024x768 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startkde &              //这些内容是我刚修改过的,把以上几行的注释都去了,没错误吧?(胡球改!)
                   //不过我不确定到底用kde还是gnome,不确定自己的是哪个图文界面。水平次没办法:)
~
"~/.vnc/xstartup" 13L, 346C

3、[root@local ~]# vncserver -kill :1
Killing Xvnc process ID 18765
kill 18765: 没有那个进程

(注意:它提示说没那个进程!又遇见鬼了!)[到此为止我估计已经遇到问题了!!!]
我重启:
[root@local ~]# vncserver restart

usage: vncserver [:<number>] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 <Xvnc-options>...

       vncserver -kill <X-display>

[root@local ~]# vncserver

New 'local:1 (root)' desktop is local:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/local:1.log

以上是我又运行了下vncserver

然后我在机子上(我实际操作的电脑是Windows)用  RUN VNC Viewer 在server栏输入:192.168.1.108:1,其他默认,cONNECTION REFUSED!(10061);输入192.168.1.108:5901,Connection refused;5801也是同样结果,连不上!
请各位兄台检查!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-22 17:18:38 | 显示全部楼层
打扰一下,顺便贴出此时我的/root/.vnc/local:1.log文件内容:
[root@local ~]# vi /root/.vnc/local:1.log

Couldn't open RGB_DB '/usr/X11R6/lib/X11/rgb'

Xvnc version 4.0 - built Jun 14 2004 12:01:28
Underlying X server release 40201000, The XFree86 Project, Inc


Tue May 22 16:56:52 2007
vncext:      VNC extension running!
vncext:      Listening for VNC connections on port 5901
vncext:      Listening for HTTP connections on port 5801
vncext:      created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

Fatal server error:
"~/.vnc/local:1.log" 34L, 1416C
Couldn't open RGB_DB '/usr/X11R6/lib/X11/rgb'

Xvnc version 4.0 - built Jun 14 2004 12:01:28
Underlying X server release 40201000, The XFree86 Project, Inc


Tue May 22 16:56:52 2007
vncext:      VNC extension running!
vncext:      Listening for VNC connections on port 5901
vncext:      Listening for HTTP connections on port 5801
vncext:      created VNC server for screen 0
error opening security policy file /usr/X11R6/lib/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

Fatal server error:
could not open default font 'fixed'
xrdb: Connection refused
xrdb: Can't open display 'local:1'
xmodmap:  unable to open display 'local:1'
xhost:  unable to open display "local:1"
Launching a SCIM process with x11...
Loading socket Config module ...
Creating backend ...
Loading x11 FrontEnd module ...

(gnome-session:18971): Gtk-WARNING **: cannot open display:
Failed to launch SCIM.
Smart Common Input Method 1.4.4


谢谢!
回复 支持 反对

使用道具 举报

发表于 2007-5-23 00:33:45 | 显示全部楼层
Post by Feraligatr
是~/.vnc/xstartup
不是你说的~/.xxx/.yyyy


笔误,我也没说是~/.xxx/.yyyy啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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