Tuesday, September 21, 2010

Setting up LAMP (Apache 2, MySql 5, PHP 5.3) on CentOS 5.5

Step 1: Installing Apache and PHP

# yum install yum-priorities
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm
# yum install httpd
# yum install php53-pear php53 php53-cli php53-common \
php53-devel php53-gd php53-mbstring php53-mcrypt \
php53-mysql php53-pdo php53-soap php53-xml php53-xmlrpc \
php53-bcmath php53-pecl-apc php53-pecl-memcache

Now we are done installing Apache 2 and PHP 5.3 on the server.

To test

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

we paste the following in the phpinfo.php file:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
Finally...

# chkconfig httpd on
# service httpd start

Now opening the browser we can see the configuration information of our php setup on http://[server-ip]/phpinfo.php.

Step 2: Installing MySql

To install mysql we do the following...

# yum install mysql mysql-devel mysql-server

now starting the server...

# /etc/init.d/mysqld start

to set the password for root...

# mysqladmin -u root password yourrootsqlpassword

We are done...

Step 3: phpMyAdmin
Though not necessary, I always like to have phpMyAdmin installed with LAMP as MySQL client.

Note: I have used the then current version 3.7.7. For current version check phpMyAdmin download page.

# cd /var/www/html
# wget -c http://prdownloads.sourceforge.net/phpmyadmin/
phpMyAdmin-3.7.7-english.tar.gz?download
# tar xvfz phpMyAdmin-3.7.7-english.tar.gz
# mv phpMyAdmin-3.7.7-english phpmyadmin
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php

We open the config.inc.php file and change the auth_type from cookies to http.

# vi config.inc.php
$cfg['Servers'][$i]['auth_type'] = ‘http‘; # default is cookies
Restart the server...

# service httpd restart

Now we have our phpMyAdmin page at http://[server-ip]/phpmyadmin/

No comments: