This requires a few steps because XAMPP requires root privileges to run. These instructions assume you have installed XAMPP in the default /opt/lampp/ folder in Ubuntu 18.04.
1. Create a bash script to launch XAMPP GUIOpen gedit and type:
- Code: Select all
#!/bin/bash
/opt/lampp/manager-linux-x64.run
Save this as xampp_launcher.sh. I have a folder for bash scripts like this in my home folder called 'scripts,' but you can save this wherever you like. You will need the path for the next step.
2. Give the script correct permissionsThis script will not open XAMPP yet because it does not have sudo rights. To get this to work open terminal and enter one line at a time:
cd /path/to/script/
sudo chown root:root xampp_launcher.sh
sudo chmod 700 xampp_launcher.sh
This has given the script the necessary permissions, but now we need it to run without having to enter the sudo password. So the next step is to exempt it in the sudoers file.
3. Exempt script from needing sudo passwordIn the terminal enter:
- Code: Select all
sudo visudo
This will launch the sudoers file within terminal. It allows us to make changes to sudo users file without the risk of locking ourselves out by mistake.
Around line 25, you'll see this line:
%sudo ALL=(ALL:ALL) ALLBelow that line, insert the following line, where username is your username:
- Code: Select all
username ALL=(ALL) NOPASSWD: /path/to/file/xampp_launcher.sh
Exit with Ctrl + X, then press Enter to save.
4. Create the launcherYou need gnome-desktop-item-edit to easily create desktop launchers. It is not installed in Ubuntu 18.04 by default, so in terminal enter:
- Code: Select all
sudo apt-get install --no-install-recommends gnome-panel
After install is done, in terminal type:
- Code: Select all
gnome-desktop-item-edit ~/Desktop/ --create-new
This will launch the desktop launcher creator. Enter the details as follows:
Type: Application
Name: XAMPP
Command: sudo /path/to/file/xampp_launcher.sh
Click OK. The launcher should now appear on your desktop. Double click to give it a try. At this point XAMPP should launch. Next, right click the launcher and open with gedit or text editor. If there is an "Icon" value, change it to the following, or if there is no "Icon" value, just add this line at the end:
- Code: Select all
Icon=/opt/lampp/htdocs/favicon.ico
Press save and close the editor.
5. Move launcher so that it can be found in Applications drawerIf you want to be able to search for this launcher like other applications, it has to be moved to /usr/share/applications.
In terminal enter:
- Code: Select all
cd Desktop
sudo mv xampp_launcher.sh /usr/share/applications
Now when you search for XAMPP in GNOME, it will appear.
Hope this works for you.