How to Automatically Start XAMPP for a Standard User in Ubuntu

In Ubuntu, XAMPP will not auto start on boot or reboot in usual Installation. We should manually enter the command to start the XAMPP as SUDO user.

xampp

But in the case of a standard user in Ubuntu, he cannot use the sudo command as he doesn’t have the admin privilege. In many cases like computer labs where students should not be provided with the admin privilege have to use XAMPP server for their academic needs.

The solution is as given below. Once you do this solution as a privileged user, XAMPP starts automatically while booting into your system (even if you are using unprivileged standard user).

Usually, in Linux, XAMPP will be installed inside the folder /opt/lampp.

Steps

  1. Open gedit and create a file as given using the terminal.
    sudo gedit /etc/init.d/lampp
    
  2. Paste these commands in the newly opened gedit window.
    #!/bin/bash
    /opt/lampp/lampp start
    

    Save and close the gedit. Change the location to your XAMPP folder accordingly (if not in /opt/lampp).

  3. Make this file executable.
    sudo chmod +x /etc/init.d/lampp
    
  4. Run this command to install the init script to all run level.
    sudo update-rc.d lampp defaults
    
  5. Now make a new folder with some arbitrary name in the Desktop folder of the standard user. For this, you have to login into that user. In my case, I named the folder as site.
  6. After making the folder, login back as the admin user.
  7. Now we want to make a link from the htdocs folder to the newly created folder site. For this type this command.
    sudo ln -s /home/user_name/Desktop/site/ /opt/lampp/htdocs/site
    

    Change the user_name to the standard username.

  8. Now restart the system and login as the standard user.
  9. Type the following command to create the PHP version file.
    echo "<?php phpinfo(); ?>" > /home/user-name/Desktop/site/index.php
    
  10. Now open your web browser and type localhost/site . If this shows your PHP version, everything is working fine.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s