Sunday, December 29, 2013

How To Configure a LAMP Server

Hello... Friends, Today I am going to Disuse about LAMP ( LINUX Apache Mysql Php ) Server Configuration. Basically we use LAMP Server to Run website in LINUX. means to say :

OS : Linux ( Here i am using CentOS )
Web server : Apache
Database     : MySql
platform      : PHP

So Let's Start

Here I am going to divide the tutorial into parts as :

Part 1 : Apache installation 

Step 1 : install the apache as

# yum install httpd 


httpd is Apache package .
Now start the httpd service
  # service httpd start
now we need to set the service auto start so that it will start automatically when we restart the system for that run command
  # chkconfig httpd on
Step 2 : verify our service is running or not for that open your browser & open system ip address. In my case my ip address is 192.168.56.101 so i need to open http://192.168.56.101



kk Now we can see our apache service is running properly
Apache default document root is /var/www/html
the Apache Default Configuration file is /etc/httpd/conf/httpd.conf  for additional secure httpd configuration read article as Secure Apache Configuration

Now we complete our First part of LAMP Configuration.

Part 2 : MySql Database Installation

Step 1 : Install the MySql as # yum install mysql mysql-server 



Now Start the service as # /etc/init.d/mysqld start else we also use command # service mysqld start
now we need to set service auto start  # chkconfig mysqld on

Step 2 : Next we need to install secure mysql
# mysql_secure_installation 



next we need to create password for remote user , remove test user , remove extra privileges etc.


follow the configuration as shown in images


well now we need to test we install it correctly or not as


Well we install mysql correctly.

Part 3 : php Installation 

step 1 : Install the php as # yum install php



now restart Apache
 # service httpd restart
so here we install php too
Step 2 : now we need to test the php installed successfully or not now as we know the root directory for web server is /var/www/html we need to create a test file in the same directory so # vi /var/www/html/info.php

& type as

<?php
phpinfo ();
?>

Step 3 : now we need to open this file in the browser as http://192.168.56.101/info.php
**Note : remove this file after testing this file contains all information of you system server


Part 4: phpMyAdmin Installation 
phpMyAdmin is a web interface through which you can manage your MySql database.
To Do so we we need to enable the RPMforge repositry on our CentOS system as as phpMyAdmin is not available in the official CentOS 6.4 repositry :

Step 1: Download & enable RPMforge repositry 

Now Import the RPMforge GPG key:

# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

ok now if you are working on x86  64 system:

# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.e16.rf.i686.rpm

if you are working on i386 system:
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.e16.rf.i686.rpm

Step 2: now install phpmyadmin

# yum install phpmyadmin



well now configure phpmyadmin
phpmyadmin configuration file is also in the /etc/httpd/conf.d/phpmyadmin.conf  now open this with editor as # vi /etc/httpd/conf.d/phpmyadmin.conf 
Comment the Directory as shown :



Step 3 : Next we change the authentication in phpMyAdmin from cookie to http
open file as # vi /usr/share/phpmyadmin/config.inc.php



Step 4 : now restart the apache service again
# service httpd restart

now open phpmyadmin in browser as :

http://192.168.56.101/phpmyadmin 
well give root username & password & njoy


No comments:

Post a Comment