Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2123921
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2010-05-11 15:42:37

I just need the cgi server side display an html file with firefox on its own monitor(using os.system call in python),and i do not use mod_python.All like,I click on client,and then server show the html file on its screen. Here is the source code.

#!/usr/bin/env python

import cgi
import os

print 'Content-Type: text/html\n\n'

os.system('firefox --display=:0.0 test.html')


But it cannot work for me,the cgi script stopped at os.system statement,and apache2 log file shows:

    No protocol specified
    No protocol specified
    Error: cannot open display: :0.0

The above message mean that the apache2 default user www-data cannot connect to  the X session used by your login username(like djstava) and also cannot open the $DISPLAY.

First I think the simplest method to solve it is changing the apache2 default user www-data to the system login username djstava.

sudo vi /etc/apache2/envvars

    export APACHE_RUN_USER=djstava
    export APACHE_RUN_GROUP=djstava

Restart the apache2,it works,firefox show the html file clearly.
But when I reboot the system,the /var/log/apach2/error.log also write down the error message unfortunately.

And second,I change the apache2 default user back to www-data,all i have to do is let the www-data gaining the accesss to the X display owned by user djstava.

    sudo xhost +local:www-data

Now everything works well.


djstava
阅读(2200) | 评论(0) | 转发(0) |
0

上一篇:Lucid Lynx 3D Effect

下一篇:Irxevent on startup

给主人留下些什么吧!~~