Installation of Linux, Apache, MySQL, PHP (LAMP) on CentOS 6

About LAMP-Stack

The acronym LAMP represents Linux, Apache, MySQL and PHP. LAMP-stack is an open source software group that is utilized for managing web servers. As CentOS  is previously running on the server on Linux, you only need to consider installation of the rest of the group.

Installation

The user needs to have root privileges on the virtual private server for following the steps given in this tutorial.

Step One – Installation of Apache & MySQL

Apache is an open source and free software that is utilized for controlling over half of the web servers running across the globe. For installing Apache, open a terminal and type this command:

sudo yum install httpd

On the completion of installation, root password MySQL can be set:

sudo / usr / bin / mysql_secure_installation


Now you will be required to type in your existing root password. But as you have deployed MySQL just now, you do not have the password, so press ‘Enter’ and leave it blank.

Now type in the current password for the root directory if you have it or press ‘Enter’ to leave it.
Next you will be asked if you would like to set the root password. Select “Y” and do as per the instructions provided. MySQL installation process is completely automated by CentOS by providing you with a series of questions, which can be answered with simple “Yes” or “No”.

 

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
Remove anonymous users? [Y / n] y                                            
 ... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y / n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y / n] y
 - Dropping test database ...
 ... Success!
 - Removing privileges on test database ...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y / n] y
 ... Success!

Cleaning up ...

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Step Two – Installation of PHP

PHP is an open source scripting programming language that finds wide usage in the creation of dynamic web pages. Open a terminal and type in the command below for deploying PHP on your virtual private server:

sudo yum install php php-mysql


PHP will be deployed as soon as you answer yes to the invitation PHP.

PHP modules

Additionally, PHP has a number of useful modules and libraries that one can add to his server. The available libraries can be browsed by entering:

yum search php-

A number of 
possible modules are then displayed by the terminal. The list is as follows:

php-bcmath.x86_64: A module for PHP applications for using the bcmath library
php-cli.x86_64: Command-line interface for PHP
php-common.x86_64: Common files for PHP
php-dba.x86_64: A database abstraction layer module for PHP applications
php-devel.x86_64: Files needed for building PHP extensions
php-embedded.x86_64: PHP library for embedding in applications
php-enchant.x86_64: Human Language and Character Encoding Support
php-gd.x86_64: A module for PHP applications for using the gd graphics library
php-imap.x86_64: A module for PHP applications that use IMAP

In order to obtain more information about each module’s execution, just type in the command below in the terminal and exchange the module name with any library’s name that you intend to learn.

yum info name of the module

Type in the command below once as you opt to deploy the module:

sudo yum install name of the module

Multiple libraries can be deployed simultaneously and name of every 
module space can be shared among them.
That’s all! Your device is now loaded with a LAMP stack! With the command given below , processes need to be established at boot server (Once Apache runs, PHP will automatically start working):

sudo chkconfig httpd on sudo chkconfig mysqld on

Step Three – RESULTS: Mind your PHP

Though LAMP has been deployed on a virtual server but it is still possible to look at different components online by developing a ‘quick’ information page about PHP. For this, you need to make a new file:

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


Now following line needs to be added:

<? Php phpinfo (); ?>


Next press “Save” and “Exit”. Now restart Apache, and this is all that is required for changes to take place in your virtual server:

sudo service httpd restart


Finish this deployment by visiting your page with PHP details (ensure replacing the demo IP-address with your own IP-address): http://12.34.56.789/info.php

KB Admin has written 28 articles

Leave a Reply