How to install and configure LAMP ( Linux, Apache, MySQL and PHP ) in Ubuntu 14.04

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

An ordinary server with Ubuntu 14.04 LTS installed. You can install it on any platform, but here the documentations are based on the Ubuntu / debian server.

3. Installation

Please proceed with the following steps:

3.1 Apache2 Installation

Type the below command for installing apache 2 package from repository.

#  apt-get install apache2

Restart apache service

# /etc/init.d/apache2 restart

Apache will start working with minimal configuration. Now Open your server-ip in the browser and You can see the apache ubuntu test page.( Default document root is located in this path /var/www/html )

apache3 ubuntu default

3.2 MySQL installation

Issue the below command to install mysql server with dependencies.

# apt-get install mysql-server

During installation it will prompt for a new password for mysql root . Give some strong password and retype the same password for confirmation.

After installation check the Database connection.

Check the service status.

# /etc/init.d/mysql status

Service is already up , Now Type this command to login

# mysql -u root -p

Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 42
Server version: 5.5.35-1ubuntu1 (Ubuntu)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>

Mysql server installation is over.

3.3 PHP installation

Type the below command to install php5.

# apt-get install php5 php5-mysql

Create a php file and paste the below code into the file to show the php configuration . Goto the default apache root path /var/www/html . create a new file info.php and paste the below code and save it.

# vi /var/www/html/info.php

Please use the following codes to create a phpinfo page.

php-info-code

Now restart the apache2 service.

# /etc/init.d/apache2 restart

Now open the file in the browser ( Eg: http://yourip/info.php ) you can see the php information page as below.
Make sure you can see the mysql details in the php information page.

ubuntu phpinfo

We have successfully configured Apache2 , mysql and php.

Leave a Reply

Your email address will not be published.