Home  >  Article  >  Backend Development  >  php调用c++程序没法写日志文件

php调用c++程序没法写日志文件

WBOY
WBOYOriginal
2016-06-13 13:16:24815browse

php调用c++程序无法写日志文件
请教,我用php的system函数调用一个c程序,这个c 程序会写一个日志文件,但是我在客户端用浏览器访问该php页面时,发现没有文件输出,而在服务器端独立运行c程序就会写文件了,请问这是怎么一回事?
大致情况如此:我的服务器是Redhat Enterprise Linux
php中这样调用c程序
system("/search/demo");
这个叫做demo的的程序是由demo.cpp编译生成而来的
demo.cpp 中有以下语句用来输出文件
ofstream fou("/var/www/html/demo.log",ofstream::app);
foufou.close();

当我在命令行中执行/search/demo,程序运行,有文本输出,而我用浏览器访问php页面时,程序依旧执行,就是文件没有输出,请问这个是怎么回事?

------解决方案--------------------
这种问题都是权限问题,看看/var/www/html/demo.log是不是Everyone可读写

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn