Installing LAMP

    Run a PHP script on Localhost on Linux


Step 1 : 

Installing Apache and Allowing Firewall Access : 

  •  Begin by installing the Apache web server. Update your package lists to ensure you get the latest software versions

Then, install Apache,


  • When prompted, confirm the installation by typing 'Y' and pressing Enter. Once the installation is complete, you can allow Apache through the firewall with:                                                                      
  • You can check the status of your firewall to verify the changes by running :

  • Now, if you navigate to your server's IP address in your web browser, you should see the Apache2 default page.                                                                                   

Step 2 :

 Installing MySQL :                                                                                                                         

  • MySQL is a robust and widely-used open-source database system. Install MySQL with the following command:                                                                                                                                                 



  • Confirm the installation by typing 'Y' and hitting Enter.                                                                                                                                                            
  • You can access the MySQL console with this command:                                                                  



  • To exit the MySQL console, simply type 'exit' and press Enter.


Step 3 :  


Installing PHP:

  • PHP is a popular server-side scripting language that, when integrated with the LAMP stack, allows you to create dynamic web applications. You can install PHP along with the necessary modules using the following command:   
  • This command installs three essential packages:
  • php: Installs PHP itself.
  • libapache2-mod-php: Used by Apache to handle PHP files.
  • php-mysql: A PHP module that enables PHP to connect to MySQL.   



  • Congratulations! You have successfully set up a LAMP stack , To create PHP file run following command and execute in browser by localhost.
    
  • Editor is open on window

  • Run PHP file on browser by localhost/fileName.php.
                              

Comments

Popular posts from this blog

Building a Database with PHP, PDO, and MySQL on Linux

Creating a Simple Library REST API with PHP