Run WINE from PHP script

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
moskernelchip
Newbie
Newbie
Posts: 1
Joined: Sun Nov 06, 2022 5:19 am

Run WINE from PHP script

Post by moskernelchip »

Hello,

I'd appreciate a lot if you could suggest the way of how to solve the problem I'm facing with.

- There is Windows application which I need to run on my WEB server (NGINX, Ubuntu 5.0)
- All works perfect via shell consol. The application run OK w/ help of WINE. Both under root and WEB user www-root (that very which runs WEB service)
- For instance, just printing WINE version
See attached file "__WINE_000.png"
- The problem appers when I try to run WINE from PHP script under WEB server
- WEB is run under www-root user
- I tried to run winecfg under www-root both from shell and PHP script
- After all .wine directory was created in /var/www/www-root/data/.wine
- I gave all the rights to this folder to www-root user
See "__WINE_002.png"
- However, running PHP script via WEB server w/ just prining WINE version gave nothing (no any output)

<?php
$output = shell_exec('wine --version');
echo "<pre>$output</pre>";
?>

- OK, I tried to set up environemntal variables HOME and/or WINEPREFIX but in also gave nothing:

$output1 = shell_exec('env HOME=/var/www/www-root/data/.wine wine --version');
$output2 = shell_exec('env WINEPREFIX=/var/www/www-root/data/.wine wine --version');

- If PHP script run the following bash script:

#!/bin/bash
whoami
echo "PATH:" $PATH
HOME="/var/www/www-root/data/.wine"
WINEPREFIX="/var/www/www-root/data/.wine"

printenv HOME
printenv WINEPREFIX

wine --version

echo "end"


I get the follwoing output:

www-root
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
/var/www/www-root/data/.wine
end

- Unfortunately, no any sighs of life from WINE :(


Please suggest the way to be dug in... Thank you in advance
Attachments
__WINE_002.png
__WINE_000.png
__WINE_000.png (8 KiB) Viewed 2227 times
Locked