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.
Previously, it was easy. Just use gksudo /opt/lampp/manager-linux-x64 in the "shortcut". Unfortunately gksudo is no longer available in Ubuntu 18.04 so we need to use "pkexec" which isn't quite as easy to use.
I've done some searching* both in this forum and on the Internet, but couldn't find a definitive answer for Ubuntu 18.04 and Mint 19... So I have written the following POLKIT policy. These are the steps to implement it in Linux Mint 19 (adapt as required for Ubuntu 18.04 and above). As Linux Mint is often used by those unfamiliar with Linux, I've deliberately made the steps very easy to follow:
1. In Terminal. Create the empty file:
- Code: Select all
sudo touch /usr/share/polkit-1/actions/com.ubuntu.pkexec.xampp.policy
2. Edit the file you just created:
- Code: Select all
sudo xed /usr/share/polkit-1/actions/com.ubuntu.pkexec.xampp.policy
- Code: Select all
<?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:
- Code: Select all
pkexec /opt/lampp/manager-linux-x64.run
- Click on the icon and select the favicon.png you created earlier
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
- Code: Select all
pkexec /opt/lampp/manager-linux-x64.run
I hope that helps anyone who wants to add XAMPP to the Menu in Linux Mint.
* Search terms I used in the forum: pkexec, polkit, policy
You are free to use the above code in any way you so wish. This code is supplied "as is" with no warranties what-so-ever. Use it totally and entirely at your own risk.
John
JQL