转载:Xlib: No protocol sp…

我在linux下访问db2cc,出现Xlib: No protocol specified的错误

转自 http://blog.sina.com.cn/s/blog_66719ff30100sdib.html

设置xhost +允许所有的服务器使用当前的X Server,默认情况下,其他服务器是无法访问本机的X Server,这时如果执行需要图形化显示的命令,就会导致上面的Xlib: connection to "172.25.198.226:1.0" refused by server的错误。

root用户下执行#xhost +

看到如下显示: access control disabled, clients can connect from any host

另,我还按照 http://blog.sina.com.cn/s/blog_4d6e44860100lyo2.html 的说法操作了一次,但当时没有成功。
但是确实设置了一下环境变量。不知道这个环境变量是否有影响。关键步骤还是“ root用户下执行#xhost +

出现错误提示:“Xlib: connection to ":1.0" refused by server”

如下处理:

实用技巧:在Linux下设置xhost方法步骤

    第一步:用root登陆linux,启动vnc服务;

    第二步:根据vnc起来的端口,设置export DISPLAY=localhost:1(1表示vnc在第一个tty上启动的),vnc的启动信息如下:

  1. [root@localhost ~]# vncserver   
  2.   
  3. New 'localhost:1 (root)' desktop is localhost:1  
  4.   
  5. Starting applications specified in /root/.vnc/xstartup   
  6. Log file is /root/.vnc/localhost:1.log   
  7.   
  8. [root@localhost ~]# export DISPLAY=localhost:1    
  9. [root@localhost ~]# xhost    
  10. access control disabled, clients can connect from any host  
[root@localhost ~]# vncserver

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

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

[root@localhost ~]# export DISPLAY=localhost:1 
[root@localhost ~]# xhost  
access control disabled, clients can connect from any host

  

    第三步:执行xhost ,并且提示“access control disabled, clients can connect from any host”才正确。 

 

 关键在于用xhost管理Xserver的访问权限


猜你喜欢

转载自blog.csdn.net/muzhiqian/article/details/52669931