Hi Vijay, althought its not necessary to install the LAMP or XAMPP stack along with PHP, but as you might know PHP is a scripting language and it needs some server to interact with. So its a good practice to install the full stack including server (Apache/Apache2) so that you can test and run your php scripts.
Now I am going to show you the step by step installation process of LAMP (Linux-Apache-MySql-PHP) stack:
1. To install Apache server, use the following command:
>>sudo apt install apache2
![](https://www.edureka.co/community/?qa=blob&qa_blobid=14305396962061973036)
2. Next start installing MySQL using the mentioned command:
>>sudo apt install mysql-server
![](https://www.edureka.co/community/?qa=blob&qa_blobid=1218945525634585619)
3. After installing Mysql, use this command to finally start installing PHP:
>>sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
![](https://www.edureka.co/community/?qa=blob&qa_blobid=11179636399224667108)
4. After successful installation of PHP, apache server should restart automatically. If not, type in the following command to restart it:
>>sudo service apache2 restart
5. To check whether server is running successfully, open browser and navigate to http://localhost/. You should see a web page like this:
![](https://www.edureka.co/community/?qa=blob&qa_blobid=232216972682989651)
6. And everything should be working fine now as all the installations are done. To check the php, type the following command in terminal and you should see a response like shown in screenshot below:
>>php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'
![](https://www.edureka.co/community/?qa=blob&qa_blobid=12286525388531902899)