如何在 Apache/Php 中使用 Wine? - '/var/www'不属于您所有
我需要从 Debian 服务器上的 php 脚本运行 Windows 命令行工具。 为此,我正在尝试 Wine。 通过终端调用 wine 和该工具工作正常: "$ wine tool.exe"
但是当从我的 php 脚本运行相同的...
exec("wine tool.exe");
...我在 Apache 错误日志中收到以下内容: wine: '/var/www' 不属于你,拒绝在那里创建配置目录
我想这是一个简单的基本 Linux 用户权限问题...... 我应该将 Wine 的用户权限更改为 www-data 吗?如何?
I need to run a windows command line tool from a php script on my Debian server.
For that, I'm trying Wine.
Invoking wine and the tool via terminal works fine: "$ wine tool.exe"
But when running the same from my php script...
exec("wine tool.exe");
...I get the following in my Apache error log:
wine: '/var/www' is not owned by you, refusing to create a configuration directory there
I guess this is a simple fundamental linux user rights problem...
Should I change the user rights for Wine to www-data? How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您应该创建一个单独的主目录来运行 Wine。创建一个属于www-data的目录,设置HOME变量,su www-data,并运行一次winecfg;然后运行tool.exe(作为该用户)。在 exec 调用中,确保设置了 HOME(尝试 exec("HOME=/tmp/wine wine tool.exe"))
You should create a separate home directory for running Wine. Create a directory which is owned by www-data, set the HOME variable, su www-data, and run winecfg once; then run tool.exe (as that user). In the exec call, make sure that HOME is set (try
exec("HOME=/tmp/wine wine tool.exe")
)您将需要使用 chown 来修改 wine 和工具的所有权。 EXE文件。
请注意,这可能会引发一些安全问题。
You're going to want to use chown to modify the ownership of wine and tool.exe.
Be advised that this could potentially open up some security concerns.
由于我运行的是 FreeBSD,我收到错误 wine: '/root' is notowned by you.创建一个名为“/var/www”的文件夹不会有太大帮助:(
Apache 以 www 身份运行,或者线程以 www 身份运行,而据我所知,主进程以 root 身份启动。如果您没有管理员权限,您可以随时尝试要求管理员在 sudoers 文件中添加一行,
我已将以下行添加到我的 sudoers 文件中,它让 Apache(www 用户)使用 sudo 作为我的用户(myuser)运行 wine。 ),而不是 www 或 root
www localhost = (myuser) NOPASSWD: /usr/home/myuser/bin/wine
在我的 PHP 脚本中,我有这样的内容:
exec("HOME=/usr/home/myuser sudo - u myuser /usr/home/myuser/bin/wine /usr/home/myuser/test.exe”
到目前为止似乎有效。
Since I'm running FreeBSD I get the error wine: '/root' is not owned by you. Creating a folder called '/var/www' won't be of much help :(
Apache is running as www, or the threads are, while the main process starts as root as far as I know. If you don't have any admin rights, you can always try to ask the admin to add a line in the sudoers file.
I've added the following line to my sudoers file and it let's Apache (the www user) use sudo to run wine as my user (myuser), instead of as www or root.
www localhost = (myuser) NOPASSWD: /usr/home/myuser/bin/wine
In my PHP script I have something like this:
exec("HOME=/usr/home/myuser sudo -u myuser /usr/home/myuser/bin/wine /usr/home/myuser/test.exe"
Seems to work so far.
我正在使用 CentOS 5.5 Linux(与 RHEL 相同),刚刚从我的家复制了 .wine 目录并递归地更改了所有者:
顺便说一句,对于一些更棘手的 Windows 程序,我必须安装 Xvfb(rpm 包名称:xorg-x11-server-Xvfb)并从 /etc/inittab 内部运行它在 :1 处,然后将 DISPLAY 设置为
localhost:1
,然后再从我的 Web 脚本启动 Wine。I'm using CentOS 5.5 Linux (same as RHEL) and have just copied the .wine directory from my home and changed the owner recursively:
BTW for some trickier Windows program I had to install Xvfb (rpm package name: xorg-x11-server-Xvfb) and run it from inside of /etc/inittab at :1 and then set DISPLAY to
localhost:1
before starting Wine from my web script.看起来无害,只要 wine 可以在没有配置目录的情况下运行。
尝试看看 wine 是否可以在命令行上使用指定的配置目录运行。如果没有,您可以做两件事:要么将现有的(例如,来自您的用户的)wine 配置目录复制到 /var/www 中,要么忽略此警告并将 STDERR 输出重定向到其他地方:
Seems harmless, as long as wine can function without configuration directory.
Try and find out if wine can run with a specified configuration directory on the commandline. If not there's two things you can do: either you copy an existing (from your user for instance) wine config directory into /var/www or you just ignore this warning and redirect STDERR output somewhere else:
或者...你可以跳过整个 sudo 事情。启动 wine 在您的主目录中生成一个配置文件,然后要求管理员对您的 wine 配置文件执行 chown www:users .wine 。
Apache 现在应该拥有使用您的配置文件运行 wine 所需的权限。
www 用户在 linux 上似乎有另一个名字...
exec("HOME=/usr/home/myuser /usr/home/myuser/bin/wine /usr/home/myuser/test.exe"
Or... you could skip the whole sudo thing. Start wine to generate a config file in your home directory, then ask the admin to do a chown www:users .wine on your wine config files.
Apache should now have the needed rights to run wine using your config file.
The www user seems to have another name on linux...
exec("HOME=/usr/home/myuser /usr/home/myuser/bin/wine /usr/home/myuser/test.exe"
已解决
所以最后,使用“mono”命令并运行 PHP 脚本。
这是我的命令:
要安装单声道,请点击此链接。
安装 mono
感谢
Raja Chakraborty
SOLVED
So Finally, used 'mono' command and run through PHP script.
Here is my command:
To Install mono please follow this link.
Install mono
Thanks
Raja Chakraborty