How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

Introduction:

The group of open source software that is usually installed together to enable a server to host dynamic websites and web apps is called a “LAMP” stack. The latter is actually an acronym which represents the Linux OS, with the Apache web server which process dynamic content and MySQL database where site data is stored.

In the following guide, we will install a LAMP stack on the Ubuntu distribution.

Ubuntu will fulfill our first requirement: a Linux operating system.

download link: ubuntu

Step 1: Install Apache

The Apache web server forms part of the most popular web servers in the world. It has a well-documented structure , provides a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standard, which makes it a great default choice for hosting a website.

Apache can be  easily installed  using Ubuntu’s package manager, apt. A package manager allows us to install most software without doing much  from a repository maintained by Ubuntu.

we can start by typing these commands:

1. $ sudo apt-get update

update

2. $ sudo apt-get install apache2

apache

Since we are using a sudo command, these operations get executed with root privileges. It will ask you for your regular user’s password to verify your intentions.

Once the password has been entered , apt will tell you which packages it plans to install and how much extra disk space they’ll take up. Press Y and hit Enter to continue, and the installation will proceed.

when the installation is done you can do a spot check right away to verify that everything went as planned by visiting your server’s public IP address in your web browser:http://localhost/ or http://server-ip-address/.

You will see the default Ubuntu 16.04 Apache web page, which is there for informational and testing purposes. It should look something like this:

it-works

note: If you see this page, then your web server is now correctly installed and accessible.

you can also check on the status of apache by using this command :

$ systemctl status apache2

apache-status

Step 2: Install MySQL

Since our web server is  up and running, we are ready to install MySQL. MySQL is a database management system. Principally, it will arrange and allow access to databases where our site can store information.

Again,  apt can be used to acquire and install our software. But, we will also install some other “helper” packages that will assist us in getting our components to communicate with each other:

$ sudo apt-get install mysql-server

mysql

Regardless of how you installed it, MySQL should have started running automatically. To test this, check its status.

$ systemctl status mysql.service

Your output should be similar to this :

testsql

If MySQL isn’t running, you can start it with:

sudo systemctl mysql start

You now have a basic MySQL setup installed on your server.

Step 3: Install PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a common open-source general purpose scripting language that is usually used for web development and can be embedded into HTML. It connects to our MySQL databases to get information, and hand the processed content over to our web server to display.

We’re going to add some helper packages as well, so that PHP code can run under the Apache server and talk to our MySQL database:

$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

php

Test  your php version:

checkphpversion

To test that our system is configured properly for PHP, we can create a very basic PHP script.

The script will be called as “info.php”. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the “web root”.

In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:

$ sudo nano /var/www/html/info.php

This will open a blank file. We want to put the following text, which is valid PHP code, inside the file:


                                                            info.php

That’s it. Your LAMP stack is ready to use. Feel free to comment and leave your reviews about my post. If there is something or that i should add ,notify me .

Advertisements

One thought on “How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

  1. Pingback: HOW TO INSTALL DRUPAL. – SecureNet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s