Ubuntu 18.04 XAMPP 桌面图标“启动应用程序时出错”

eri*_*ric 4 xampp

我在桌面上创建了一个图标并输入以下代码:

[Desktop Entry]
Encoding=UTF-8
Name=XAMPP Control Panel
Comment=Start and Stop XAMPP
Exec=gksudo /opt/lampp/manager-linux-x64.run
Icon=/opt/lampp/htdocs/favicon.ico
Categories=Application
Type=Application
Terminal=false
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,我收到“启动应用程序时出错”

如果我进入终端并输入sudo /opt/lampp/manager-linux-x64.run,它工作正常。我尝试更改gksudo为,sudo但这也不起作用。

我究竟做错了什么?

Dan*_*nez 10

这在Ubuntu 18.04上对我有用

首先你需要安装包“nautilus-admin”:

sudo apt-get update
sudo apt-get install nautilus-admin
Run Code Online (Sandbox Code Playgroud)

在“/usr/share/polkit-1/actions/xampp.policy”中创建一个新文件:

sudo nano /usr/share/polkit-1/actions/xampp.policy
Run Code Online (Sandbox Code Playgroud)

添加此内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>

  <action id="org.freedesktop.policykit.pkexec.run-xampp">
    <description>Run the Xampp Control Panel</description>
    <message>Authentication is required to run the Xampp Control Panel</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/opt/lampp/manager-linux-x64.run</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
  </action>
</policyconfig>
Run Code Online (Sandbox Code Playgroud)

最后,创建一个新文件或编辑桌面条目/usr/share/applications/xampp-control-panel.desktop并替换Exec=gksudo /opt/lampp/manager-linux-x64.runExec=pkexec /opt/lampp/manager-linux-x64.run

sudo nano /usr/share/applications/xampp-control-panel.desktop

[Desktop Entry]
Encoding=UTF-8
Name=XAMPP Control Panel
Comment=Start and Stop XAMPP
Exec=pkexec /opt/lampp/manager-linux-x64.run
Icon=/opt/lampp/htdocs/favicon.ico
Categories=Application
Type=Application
Terminal=false
Run Code Online (Sandbox Code Playgroud)

我希望它有帮助。