There are several ways to install php in Linux environment. XAMPP is the best way I found to configure PHP in Ubuntu. By installing XAMPP, you can easily access to PHP files with MYSQL queries. I will explain how to install. First download XAMPP from here. After you downloaded the setup file, you should o to the directory in which it is included and then follow the below steps. You have to change the file permissions to execute the file using chmod command. Then you can start the setup file using the second step.
After that, a setup wizard will be opened and simply click next several times and click finish. The screenshots of steps have been uploaded.
Then the GUI of XAMPP will be opened. You can start Apache and Mysql services to access php files. If you want to test whether php is working or not, just type the word - localhost in URL bar of your web browser. If php is working, output browser page will be like this.
But here you will have an issue. After closing GUI of XAMPP very first time, you can never find the launcher icon again in Ubuntu search. You have to do some steps to be able to start XAMPP GUI with the icon. My next article will be based on this. Wait for it.
You can use following commands in the terminal to start and stop xampp service. You will be asked the password. After giving it, services should be started.
Alternative way to start XAMPP
If you are getting a failure message in the terminal saying Apache is failed to start, you have to stop the services and restart it. Following codes will solve your problems.
Now you can access php files easily. Enjoy wonder of PHP through your machine!