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.
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.
- Open gedit and create a file as given using the terminal.
sudo gedit /etc/init.d/lampp
- 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).
- Make this file executable.
sudo chmod +x /etc/init.d/lampp
- Run this command to install the init script to all run level.
sudo update-rc.d lampp defaults
- 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.
- After making the folder, login back as the admin user.
- 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.
- Now restart the system and login as the standard user.
- Type the following command to create the PHP version file.
echo "<?php phpinfo(); ?>" > /home/user-name/Desktop/site/index.php
- Now open your web browser and type localhost/site . If this shows your PHP version, everything is working fine.