Setting up LAMP server(linux apache mysql and php) in centos

Pranaam to all bhai ji _/\_

Today we will learn , how to setup LAMP server in CentOS
LAMP stands for
L Linux OS
A Apache web server
M MySQL server
P PHP (perl/python too ;) )

there are 2 methods to install these packages , first one is by downloading package source files of each and then we can install them
second one is by using apt-get (for ubuntu) and yum(for centos) command

second one is easy one for beginners :)
lets start :)
i am going for centOS first :)
before going to installation , we need to update our repository so that yum can download essential packages which will be required during package installation
we need to add extra repository that is epel
here is the link for epel file
linux which i am using is centos 6.4 and its architecture is i386 (32 bit)
so epel file link for me is

you can check system architecture by running command uname -i
if it shows x86_64 , means your system is 64 bit hardware and you need epel file according to your architecture

ok , download required epel file using wget command or browser

ok , copy this epel file to /etc/yum.repos.d directory
and then install it (we can install it without moving to /etc/yum.repos.d directory too ) using  rpm command 
rpm command is to use for installing .rpm files
command is  rpm -i  rpm_file_name 
here rpm is installer that will install .rpm file
-i option is  for install
rpm_file_name is the name of .rpm file name 
in my case .rpm file name is epel-release-6-8.noarch.rpm
 so command will be like this 
rpm -i   epel-release-6-8.noarch.rpm 

now we will create yum repository  again so that package links that are stored in epel, can be accessible by yum installer .
procedure is simple , just run this command   createrepo  /etc/yum.repos.d

now we are ready to install apache , mysql and php using yum installer :D

Apache web server installation using yum:-
 apache web server package is known as httpd .
yum command to install a package is  yum install  package_name
so for apache web server installation our command will be  
yum install httpd
and OS will ask whether you want to install package or not
type y and press enter

or use command yum install httpd -y and we wont prompt for package installation confirmation .

this is apache installation using yum . 
for starting  apache , use command service httpd start
for stopping apache , command is  service httpd stop
for restart, service httpd restart 
if you want, whenever you start/restart your OS , apache should start automatically

use command  chkconfig httpd on this command will checkmark httpd as a service that will start automatically when OS will start/restart 

Installing MySQL server:-
MySQL server package is  mysql-server
for mysql installation yum installer command is yum install mysql-server -y 

after completion of installation , start mysql service by using command service mysqld start
now we need to setup root account password for mysql
run command mysql_secure_installation but dont forget to start mysql before going to this step else it will though error

we will prompt for "enter current password for root (enter for none)", just press enter button and after this step we are going to set password for root account
type y , press enter
type password that you want to set
retype password
and press enter

complete some more steps and its done :)

you can login to mysql using command
mysql -u username -p
here -u for username with which you want to login to mysql
 username is account name of user in mysql
-p for password
i am going to login to mysql server via root account
so command will be
mysql -u root -p

press enter and type password that you supplied for root account in mysql installation (in my case its indishell ^_^)

for starting mysql server , command is service mysqld start
stopping mysql , service mysqld stop
restarting sql server , command is service mysqld restart
use chkconfig mysqld on if you want to start mysql on system boot/reboot

Installing PHP using Yum:-
php package name is php for centos/redhat/fedora
for php installation run command
yum install php 

  php version 5.3.3 is going to install
once php installation completed , just restart you apache web server (service httpd restart ) and your LAMP server is ready

if you want to install phpmyadmin too, just follow these steps
run command yum install phpmyadmin and this command will start installation of phpmyadmin

after installation , we need to symlink phpmyadmin in /var/www/html directory so that we can access it via browser
but first of all we need to find out accurate name of phpmyadmin under /usr/share directory
because we will use that name in creating symlink so that we can access phpmyadmin application using browser

in my case its  phpMyAdmin . ok lets move ;)
enter in directory /var/www/html and this command
ln -s  /usr/share/phpMyAdmin  phpmyadmin

this command will create shortcut of  /usr/share/phpMyAdmin into /var/www/html folder with name phpmyadmin
and now can access phpmyadmin using browser ^_^
just type in your browser and fill username password of mysql user(you can use root account username password that you created in mysql)
and you will be redirected to this page

 enjoy your LAMP server 8|
your LMAP server is ready to use , you can use it for application which requires php, mysql and apache
just put your scripts in /var/www/html folder and create database/upload database via phpmyadmin (if script is database dependent )

Thank You
Love to :-Zero cool , Team IndiShell Leads , Hardeep bhai and AR AR bhai ji
Share this post


:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

© 2009 Start With Linux | Mannu Linux
Designed by cyb3r.gladiat0r
Posts RSSComments RSS
Back to top