We need Apache Service to run php codes. Now, I hope you've already installed Apache Service in your Ubuntu PC. If you have not installed it, please click here. Then, follow the below steps.
1. Click Open Folder Location.
2. Double click htdoc.
3. Right Click in htdoc and Click Open In Terminal.
4. Type nano in the Terminal and press Enter. And then, type the following php codes.
echo 'Welcome to TNW!';
5. Press Ctrl and O together at the same time.
6. Give file name (eg, test.php) and press Enter.
7. Press Ctrl and X together at the same time to exit from current Terminal.
8. Open Web browser and type localhost/test.php and press Enter. Then, you will see Welcome to TNW!. Now, we have successfully created first php file in Ubuntu.
What do you think?
Send us feedback!