Skip to content

Instantly share code, notes, and snippets.

@JQL
Last active March 25, 2023 16:18
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save JQL/122553c01aa64553414d1d60a62934eb to your computer and use it in GitHub Desktop.
Save JQL/122553c01aa64553414d1d60a62934eb to your computer and use it in GitHub Desktop.
How to use pkexec to add XAMPP to the Linux Mint Menu. Note, it also works on Ubuntu and Ubuntu Mate with suitable changes.
<?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>
<vendor>Apache Friends</vendor>
<vendor_url>https://www.apachefriends.org/index.html</vendor_url>
<icon_name>xampp</icon_name>
<action id="com.ubuntu.pkexec.xampp.policy">
<description>Run XAMPP Control Panel</description>
<message>Authentication is required to run the XAMP Control Panel</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</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>
How to use pkexec to add XAMPP to the Linux Mint Menu. Note, it also works on Ubuntu and Ubuntu Mate with suitable changes.
I use XAMPP in Linux, both Ubuntu and Mint, but I don't want to start it as a Service. Instead I want a menu icon and, for Linux Mint, a quick launch icon, so I can start the XAMPP Control Panel as and when I wish.
These are the steps to implement it in Linux Mint:
1. Create the empty file: sudo touch /usr/share/polkit-1/actions/com.ubuntu.pkexec.xampp.policy
2. Edit the file: xed admin:///usr/share/polkit-1/actions/com.ubuntu.pkexec.xampp.policy and copy and paste the following xml into it
<?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>
<vendor>Apache Friends</vendor>
<vendor_url>https://www.apachefriends.org/index.html</vendor_url>
<icon_name>xampp</icon_name>
<action id="com.ubuntu.pkexec.xampp.policy">
<description>Run XAMPP Control Panel</description>
<message>Authentication is required to run the XAMP Control Panel</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</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>
3. Save the file and exit xed.
4. Create a png image of the favicon file in /opt/lampp/htdocs
5. To open the Menu Editor in Linux Mint: right click on the Menu button. Click on Configure. Click on Menu. Click on Open the Menu Editor.
6. In the left panel, click on Internet then click on New Item
7. Enter the following in the dialogue:
Name: XAMPP
Command: pkexec /opt/lampp/manager-linux-x64.run
Click on the icon and select the favicon.png you created earlier
8. Save and exit the Menu Editor.
9. In the Menu right click the newly created XAMPP icon and click on + Add to panel
You should now be able to launch XAMPP from the menu and the quick launch bar. As a bonus entering pkexec /opt/lampp/manager-linux-x64.run into terminal will also start the XAMPP Control Panel.
@jeremyb31
Copy link

rather than use sudo with a GUI program, you could do xed admin:///usr/share/polkit-1/actions/com.ubuntu.pkexec.xampp.policy

@faisal95bd
Copy link

Thanks! now it's working.

@faisal95bd
Copy link

I tried many time with gksudo -_- !! I got the solution now.

@easterncoder
Copy link

Thanks! Have never used XAMPP on Linux before. I just use what's packed with the distro. However I need to teach some guys PHP and XAMPP seems to be the best way to get them started (they are on different operating systems). Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment