I would like to start with a little introduction about XAMPP.
X – cross platform, different operating systems ( Windows, Linux, Mac OS X)
A-Apache (HTTP server)
P-PHP (Scripting Language)
P-Perl (Script programming language)
Use: PHP script is executed on server so if you want to run php script on local machine you need local server XAMP provide you local server (Apache). Well, it can be used for all the above as well.
I feel rather installing all the above separately we can simply install Xampp all at once.
Steps to Install XAMPP:
- Download the latest version of xampp from https://www.apachefriends.org/download.html choose the version and OS you want.
- Open the terminal ctrl+alt+t and then browse (cd) to the directory where the file was downloaded and run the below commands, you can replace the name with the name of your installed file
sudo -i sudo chmod 755 xampp-linux-x64-7.1.1-0-installer.run sudo
This will extract all the packages to the /opt/lampp directory
- Then you have to store the php files you want to run in /opt/lampp/htdocs and for that you need to change the permissions of htdocs, for that run the command
sudo chmod 777 /opt/lampp/htdocs
- Now copy the php file in /opt/lampp/htdocs
- Then you need to go ahead, and start the service, and see if it works
- To check, you can browse the following urls in your browser
http://localhost http://localhost/file_name.php http://localhost/phpmyadmin
You may see the following page
This means that another daemon of mysql is already running, so we need to stop lampp and mysql and restart lampp again, run the following commands
sudo /opt/lampp/lampp stop sudo service mysql stop sudo /opt/lampp/lampp start
If you see the following page it may mean that another daemon of Apache is already running and you need to stop lampp and apache and then start apache again.
Run the following commands
sudo /opt/lampp/lampp stop sudo service apache2 stop sudo /opt/lampp/lampp start
And to remove this problem permanently we delete the previously installed services.
- To check if they exists you may run the following commands, I am doing it here for apache
- If the version is displayed so the next step will be to remove it
sudo apt-get remove apache2
- You may repeat the same for the rest of the service if error persists.