Installation Guide of Apache, PHP and MySQL Server on Linux

Welcome, tech enthusiasts and aspiring web developers! Today, we embark on a journey into the heart of web server technology, exploring the seamless integration of the powerful trio—Apache, PHP, and MySQL—on the robust foundation of the Linux operating system.

The Linux Advantage

In the realm of open-source operating systems, Linux stands tall as a beacon of stability, security, and flexibility. Its versatility makes it the preferred choice for hosting web applications, and when coupled with the LAMP stack (Linux, Apache, MySQL, PHP/Python/Perl), it becomes an unstoppable force in the world of web development.

A Symphony of Services: Apache, PHP, and MySQL

At the core of many dynamic websites and web applications lies the triumvirate of Apache, PHP, and MySQL. Let's break down the role each component plays:

Apache - The Web Server Extraordinaire

Apache, the venerable web server, serves as the gateway between your applications and the vast expanse of the internet. Renowned for its reliability and scalability, Apache ensures that your web content reaches its audience swiftly and securely.

Installation Steps:

Step 1: Open the terminal on Linux, you can use a keyboard shortcut ALT + CTRL + T

Step 2: Enter the Linux command- sudo apt install apache2


Step 3: Type Y to continue installation-
             You will able to see the installation as shown in screenshot below:

    Linux will install the apache server on System like shown below-


Step 4: Finally Apache Server is installed on Linux System.
             Check if Apache is installed or not by command- apt show apache2
              If it is successfully installed, the screen will show like below:


This shows Apache Server is successfully installed on Linux System

PHP - The Server-Side Scripting Maestro

PHP, the Hypertext Preprocessor, adds the dynamic element to your web pages. As a server-side scripting language, PHP empowers developers to embed code directly into HTML, creating interactive and feature-rich websites.

Installation Steps:

Step 1: Open the terminal on Linux, you can use a keyboard shortcut ALT + CTRL + T

Step 2: Enter the Linux command- sudo apt install php libapache2-mod-php

Step 3: Type Y to continue installation-
             You will able to see the installation as shown in screenshot below:

     Linux will install the PHP server on System like shown below-


Step 4: Finally PHP Server is installed on Linux System.
             Check if PHP is installed or not by command- apt show php
             If it is successfully installed, the screen will show like below:


This shows PHP Server is successfully installed on Linux System

MySQL - The Database Dynamo

MySQL, a powerful and open-source relational database management system, is the storage backbone of many dynamic web applications. It efficiently handles data management, retrieval, and storage, providing a robust foundation for your website's backend.

Installation Steps:

Step 1: Open the terminal on Linux, you can use a keyboard shortcut ALT + CTRL + T

Step 2: Enter the Linux command- sudo apt install mysql-server

Step 3: Type Y to continue installation-
             You will able to see the installation as shown in screenshot below:


Linux will install the MySQL server on System like shown below-


Step 4: Finally MySQL Server is installed on Linux System.
             Check if PHP is installed or not by command- apt show mysql-server
             If it is successfully installed, the screen will show like below:


This shows MySQL Server is successfully installed on Linux System

Running the first PHP script on Apache Server:

Step 1: Create a Sample PHP Script

              1Create a simple PHP script. Open a text editor and create a file named 'index.php':

             2.
Save this file in the default web server directory, typically '/var/www/html/'

To go to above directory use: cd /var/www/html/ and create a file index.php using                 command: sudo nano index.php


        3. A text editor terminal GNU nano 6.0 will be open, write the sample php script and hit CTRL + O to save in the              directory.

    

Step 2: Start the Apache Server

       1. To start Apache Server use command: sudo service apache2 start


       2. To run index.php, open the web browser and type url: http:/localhost/index.php 


Following above steps you will be able run the PHP Script on Apache Server on Linux OS.

Blog by
KHUSHI

Comments