Creating an Apache2 Control Shortcut in Ubuntu (Apache2 Launcher)

August 12th 2013

I've recently been playing around with launchers in Ubuntu. One of my most used applications is Apache2. Primarily because the development I do on my laptop uses Apache2.

Anyway, I love the idea of having a shortcut on my launcher to control Apache2.

Here's what I did:

Text Snippet:
$ gedit /home/roger/Desktop/apache_launcher.desktop

Put this content in the code:

Text Snippet:
[Desktop Entry]
Name=Apache2 Control
GenericName=Apache2 Control
X-GNOME-FullName=Apache2 Control
Comment=Start, Stop, Restart, Force Reload, Reload Apache2
Exec=notify-send 'Apache2 Controller' 'This is a launcher application. Pin to your launcher and right click.'
Icon=emblem-web
Terminal=false
Type=Application
StartupNotify=true

X-Ayatana-Desktop-Shortcuts=Start;Stop;Restart;Reload;Force-Reload


[Start Shortcut Group]
Name=Start
Exec=gksu service apache2 start
TargetEnvironment=Unity

[Stop Shortcut Group]
Name=Stop
Exec=gksu service apache2 stop
TargetEnvironment=Unity

[Restart Shortcut Group]
Name=Restart
Exec=gksu service apache2 restart
TargetEnvironment=Unity

[Reload Shortcut Group]
Name=Reload
Exec=gksu service apache2 reload
TargetEnvironment=Unity

[Force-Reload Shortcut Group]
Name=Force Reload
Exec=gksu service apache2 force-reload
TargetEnvironment=Unity

Now, save the file and head back to the terminal.

Text Snippet:
$ sudo mv /home/roger/Desktop/apache_launcher.desktop /usr/share/applications
$ cd /usr/share/applications
$ sudo chmod 644 apache_launcher.desktop
$ sudo chown root:root apache_launcher.desktop

Now, if you open your applications list. Search for 'Apache' and you'll see a Globe icon. Drag this over to your launcher.

Right click on it, and you'll see the options of control.

Hope this helps you out!