linux系统已经被我们的PC机大量使用,多数应用软件主动兼容。但是由于不少杀手级应用还基于Windows系统,包括MS Office、Adobe PS等,如果安装双系统,频繁开关机切换操作极为不便。
WinApps是一个利用 RDP (Remote Desktop Protocol) 和虚拟机或容器技术,将 Windows 应用程序“流式传输”到 Linux 桌面的解决方案。包括在Linux (Ubuntu/Fedora) 和 GNOME/KDE 中运行 Microsoft Office/Adobe 等 Windows 应用程序。
它利用远程桌面的工作原理,在 Linux 宿主机上运行的 Windows VM/容器中,启动 Windows 应用,并通过 RDP 将其界面流式传输到 Linux 桌面,即使用 FreeRDP 作为后端,将 Windows 应用程序与 GNU/Linux 应用程序一起无缝渲染。因为应用软件运行在真实的 Windows 环境中,所以兼容性接近 100%。特别适合兼顾性能与兼容性、希望在 Linux 上无缝使用少量 Windows 专用生产力工具的 Linux 用户。
下面介绍安装方法。
一、准备工作
下载yaml文件,为拉取docker镜像作准备。将以下yaml文件下载到debian系统的~/winapps/目录下,如果没有该目录,则创建一个。
https://github.com/winapps-org/winapps/blob/main/compose.yaml

或者将yaml文件下载到本地windows电脑并上传到debian电脑对于目录下:

scp compose.yaml [email protected]:/home/youxin/winapps
yaml文件可以修改部分参数,其中重点参数是:      
 VERSION: "11" #11代表windows11, RAM_SIZE: "4G"  # Windows VM的内存大小. CPU_CORES: "4"  # Windows VM的 CPU 核心数量. DISK_SIZE: "64G" # 主硬盘大小.      USERNAME: "MyWindowsUser" # 访问Windows 的用户名.默认为 'MyWindowsUser'. PASSWORD: "MyWindowsPassword" # 访问Windows 的用户密码.默认为 'MyWindowsPassword'.

二、安装docker

在命令行中删除旧版本
sudo apt remove docker docker-engine docker.io containerd runc

运行sudo apt update,更新apt仓库列表,并安装依赖。

sudo apt updatesudo apt install -y curl gnupg lsb-release
添加 Docker 的官方 GPG 密钥。
curl -fsSL https://download./linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
添加 Docker 的APT 源。
 echo   "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/debian   bookworm stable" |   sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

再更新apt软件包索引。

在线安装docker引擎
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
启动Docker 服务,设置开机自动启动。
sudo systemctl start dockersudo systemctl enable docker

将当前用户加入 docker 组

sudo usermod -aG docker $USER

验证是否安装成功

docker --versiondocker info

配置 DNS(防止出现解析失败)

sudo tee /etc/docker/daemon.json > /dev/null <<'EOF'{  "dns": ["8.8.8.8", "1.1.1.1"],  "log-driver": "json-file",  "log-opts": {    "max-size": "10m",    "max-file": "3"  }}EOF

三、安装Windows VM

重启 Docker

sudo systemctl restart docker

拉取镜像

cd ~/winappsdocker compose --file ./compose.yaml up
完成后如果再次运行该命令,直接下载windows11安装介质,完成后提示点击127.0.0.1:8006的链接。

由于本次远程安装和连接,因此将127.0.0.1换成主机ip地址。弹出如下安装界面。

连接方式为VNC远程桌面,可以看到Windows11安装进度。完成后显示如下页面。

测试:下载wps并安装,可以正常运行。

后续使用的命令:

docker compose --file ~/.config/winapps/compose.yaml start # Power on the Windows VMdocker compose --file ~/.config/winapps/compose.yaml pause # Pause the Windows VMdocker compose --file ~/.config/winapps/compose.yaml unpause # Resume the Windows VMdocker compose --file ~/.config/winapps/compose.yaml restart # Restart the Windows VMdocker compose --file ~/.config/winapps/compose.yaml stop # Gracefully shut down the Windows VMdocker compose --file ~/.config/winapps/compose.yaml kill # Force shut down the Windows VM

四、安装依赖包,与linux深度集成

apt updatesudo apt install -y curl dialog freerdp3-x11 git iproute2 libnotify-bin netcat-openbsdsudo apt install freerdp3-x11 libfreerdp3-3 freerdp3-dev

五、创建 WinApps 配置文件

创建一个配置文件“~/.config/winapps/winapps.conf”,其中包含内容详见文末。

为了保护您的 Windows 密码不被泄露,请确保只能由您的用户账户访问。

chown $(whoami):$(whoami) ~/.config/winapps/winapps.confchmod 600 ~/.config/winapps/winapps.conf

六、测试 FreeRDP

运行以下命令,其中将/u和/p后面的字符改成windows本地登录用户名和密码。如果不清楚,通过VNC连接修改。

xfreerdp3 /u:"Your Windows Username" /p:"Your Windows Password" /v:192.168.122.2 /cert:tofu
注意,必须在linux桌面的终端上运行该命令,否则无法启用freeRDP。

七、运行 WinApps 安装程序

在 Windows 仍处于打开状态的情况下,运行 WinApps 安装程序。

bash <(curl https://raw./winapps-org/winapps/main/setup.sh)
弹出如下界面,点击安装(install),确认,然后一步一步默认操作。
接着开始下载有关文件并安装。
安装 WinApps 后,可以通过运行以下命令访问其他参数列表。
winapps-setup --help
八、缺点
由于采用Windows VM和远程桌面方式,是会有一定的网络延迟和性能损耗,且占用大量内存、CPU 和存储空间。
关注本公众号,回访不迷路。

>详细安装说明:

https://github.com/winapps-org/winapps

如何在linux中运行Windows应用程序,100%兼容

>”~/.config/winapps/winapps.conf”配置文件内容:

###################################   WINAPPS CONFIGURATION FILE   #################################### INSTRUCTIONS# - Leading and trailing whitespace are ignored.# - Empty lines are ignored.# - Lines starting with '#' are ignored.# - All characters following a '#' are ignored.# [WINDOWS USERNAME]RDP_USER="MyWindowsUser"# [WINDOWS PASSWORD]# NOTES:# - If using FreeRDP v3.9.0 or greater, you *have* to set a passwordRDP_PASS="MyWindowsPassword"# [WINDOWS DOMAIN]# DEFAULT VALUE: '' (BLANK)RDP_DOMAIN=""# [WINDOWS IPV4 ADDRESS]# NOTES:# - If using 'libvirt', 'RDP_IP' will be determined by WinApps at runtime if left unspecified.# DEFAULT VALUE:# - 'docker': '127.0.0.1'# - 'podman': '127.0.0.1'# - 'libvirt': '' (BLANK)RDP_IP="127.0.0.1"# [VM NAME]# NOTES:# - Only applicable when using 'libvirt'# - The libvirt VM name must match so that WinApps can determine VM IP, start the VM, etc.# DEFAULT VALUE: 'RDPWindows'VM_NAME="RDPWindows"# [WINAPPS BACKEND]# DEFAULT VALUE: 'docker'# VALID VALUES:# - 'docker'# - 'podman'# - 'libvirt'# - 'manual'WAFLAVOR="docker"# [DISPLAY SCALING FACTOR]# NOTES:# - If an unsupported value is specified, a warning will be displayed.# - If an unsupported value is specified, WinApps will use the closest supported value.# DEFAULT VALUE: '100'# VALID VALUES:# - '100'# - '140'# - '180'RDP_SCALE="100"# [MOUNTING REMOVABLE PATHS FOR FILES]# NOTES:# - By default, `udisks` (which you most likely have installed) uses /run/media for mounting removable devices.#   This improves compatibility with most desktop environments (DEs).# ATTENTION: The Filesystem Hierarchy Standard (FHS) recommends /media instead. Verify your system's configuration.# - To manually mount devices, you may optionally use /mnt.# REFERENCE: https://wiki./title/Udisks#Mount_to_/mediaREMOVABLE_MEDIA="/run/media"# [ADDITIONAL FREERDP FLAGS & ARGUMENTS]# NOTES:# - You can try adding /network:lan to these flags in order to increase performance, however, some users have faced issues with this.# DEFAULT VALUE: '/cert:tofu /sound /microphone +home-drive'# VALID VALUES: See https://github.com/awakecoding/FreeRDP-Manuals/blob/master/User/FreeRDP-User-Manual.markdownRDP_FLAGS="/cert:tofu /sound /microphone +home-drive"# [DEBUG WINAPPS]# NOTES:# - Creates and appends to ~/.local/share/winapps/winapps.log when running WinApps.# DEFAULT VALUE: 'true'# VALID VALUES:# - 'true'# - 'false'DEBUG="true"# [AUTOMATICALLY PAUSE WINDOWS]# NOTES:# - This is currently INCOMPATIBLE with 'manual'.# DEFAULT VALUE: 'off'# VALID VALUES:# - 'on'# - 'off'AUTOPAUSE="off"# [AUTOMATICALLY PAUSE WINDOWS TIMEOUT]# NOTES:# - This setting determines the duration of inactivity to tolerate before Windows is automatically paused.# - This setting is ignored if 'AUTOPAUSE' is set to 'off'.# - The value must be specified in seconds (to the nearest 10 seconds e.g., '30', '40', '50', etc.).# - For RemoteApp RDP sessions, there is a mandatory 20-second delay, so the minimum value that can be specified here is '20'.# - Source: https://techcommunity.microsoft.com/t5/security-compliance-and-identity/terminal-services-remoteapp-8482-session-termination-logic/ba-p/246566# DEFAULT VALUE: '300'# VALID VALUES: >=20AUTOPAUSE_TIME="300"# [FREERDP COMMAND]# NOTES:# - WinApps will attempt to automatically detect the correct command to use for your system.# DEFAULT VALUE: '' (BLANK)# VALID VALUES: The command required to run FreeRDPv3 on your system (e.g., 'xfreerdp', 'xfreerdp3', etc.).FREERDP_COMMAND=""# [TIMEOUTS]# NOTES:# - These settings control various timeout durations within the WinApps setup.# - Increasing the timeouts is only necessary if the corresponding errors occur.# - Ensure you have followed all the Troubleshooting Tips in the error message first.# PORT CHECK# - The maximum time (in seconds) to wait when checking if the RDP port on Windows is open.# - Corresponding error: "NETWORK CONFIGURATION ERROR" (exit status 13).# DEFAULT VALUE: '5'PORT_TIMEOUT="5"# RDP CONNECTION TEST# - The maximum time (in seconds) to wait when testing the initial RDP connection to Windows.# - Corresponding error: "REMOTE DESKTOP PROTOCOL FAILURE" (exit status 14).# DEFAULT VALUE: '30'RDP_TIMEOUT="30"# APPLICATION SCAN# - The maximum time (in seconds) to wait for the script that scans for installed applications on Windows to complete.# - Corresponding error: "APPLICATION QUERY FAILURE" (exit status 15).# DEFAULT VALUE: '60'APP_SCAN_TIMEOUT="60"# WINDOWS BOOT# - The maximum time (in seconds) to wait for the Windows VM to boot if it is not running, before attempting to launch an application.# DEFAULT VALUE: '120'BOOT_TIMEOUT="120"# FREERDP RAIL HIDEF# - This option controls the value of the `hidef` option passed to the /app parameter of the FreeRDP command.# - Setting this option to 'off' may resolve window misalignment issues related to maximized windows.# DEFAULT VALUE: 'on'HIDEF="on"