Configure LAMP (Linux, Apache, Mysql, PHP) on RHEL 6
LAMP
- Linux, Apache, MySQL and PHP, an open-source Web development platform/Web stacks, that uses Linux as the operating
system, Apache as the Web server, MySQL as the DBMS and PHP as the scripting
language. Perl or Python is often substituted for PHP
Apache - Apache provides
the mechanics for getting a Web page to a user. Apache is a stable, mission-critical-capable
server, and it runs more than 65 percent of all Web sites on the Internet.
The PHP component actually sits inside Apache, and you use Apache and PHP together to create your dynamic pages.
MySQL - MySQL
provides the data-storage side of the LAMP system. With MySQL, you have access to a
very capable database suitable for running large and complex sites. Within your
Web application, all your data, products, accounts, and other types of
information will reside in this database in a format that you can easily query
with the SQL language.
PHP- PHP is a simple and efficient programming language that provides
the glue for all the other parts of the LAMP system. You
use PHP to write dynamic content capable of accessing the data in the MySQL
database and some of the features that Linux provides.
Now we are going to configure LAMP on RHEL 6
----------------------------------------------------------------------------------------
>>>details of the directory structure going to use
Directory Structure
/usr/local/src/lamp : The Downloaded .The tar file will be saved here.
/usr/local/lamp : This where we compile, install the source code
/usr/local/lamp/apache : we will install Apache under this directory
/usr/local/lamp/mysql : we will install Mysql under this directory
/usr/local/lamp/php : we will install php under this directory
flush your firewall before you testing this
# iptables -F
# service iptables save
1:- Removing the already installed rpms
>check whether the rpm's are already there
# rpm -qa | grep httpd <-- Installed
# rpm -qa | grep mysql <-- Installed
# rpm -qa | grep php <-- Not Installed
stop the services
# service httpd stop
# service mysqld stop
removing the Packages
# rpm -e httpd
# rpm -e mysql-server
2:-Downloading the .tar file
# mkdir /usr/local/src/lamp
# mkdir /usr/local/lamp
# cd /usr/local/src/lamp
#wget ftp://ftp.nz.freebsd.org/pub/phpweb/distributions/php-5.4.8.tar.gz
#wget https://archive.apache.org/dist/httpd/httpd-2.2.22.tar.gz
#wget http://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.28.tar.gz
# yum install gcc gcc-c++ cmake ncurses-devel libxml2-devel
#tar -xvf httpd-2.2.22.tar.gz
# cd /usr/local/src/lamp/httpd-2.2.22
# ./configure --prefix=/usr/local/lamp/apache --enable-so --enable-mods-shared="most"
*/Checks some details about the machine.This script checks for lots of dependencies on your system. For the particular software to work properly/*
*/ --prefix gives the installing location of http /*
*/ --enable-mods-shared="most" : List of modules we want to enable . here i choose to enable most of the modules/*
# make
*/ Compilation of the source code /*
# make install
*/ install configuration /*
# ll /usr/local/lamp/apache
# /usr/local/lamp/apache/bin/apachectl start
# netstat -ntlp | grep httpd
Note: The default index.html is located inside the /usr/local/lamp/apache/htdocs/index.html
checking
"Now open up a browser and type http://127.0.0.1 or http://yourip you will get test page containing "It works!" "
# ln -s /usr/local/lamp/apache/bin/apachectl /etc/init.d/httpd
*/create a soft link /*
# chmod 755 httpd
3:-COMPILING MYSQL
#groupadd mysql
#useradd -g mysql mysql
#cd /usr/local/src/lamp
#ll
#cd mysql-5.5.28
#pwd
#tar -xvf mysql-5.5.28.tar.gz
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lamp/mysql -DMYSQL_DATADIR =/usr/ local/ lamp/mysql/data
#make
#make install
#chown -R mysql:mysql /usr/local/lamp/mysql
#/usr/local/lamp/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/lamp/mysql/ \--datadir=/usr/local/lamp/mysql/data/
#cp /usr/local/lamp/mysql/support-files/mysql.server /etc/init.d/mysqld
#cp /usr/local/lamp/mysql/support-files/my-medium.cnf /etc/my.cnf
#chkconfig --add mysqld # chkconfig --list mysqld
#service mysqld restart
#netstat -ntlp | grep mysql
4:-COMPILING PHP
#cd /usr/local/src/lamp/
#tar -xvf php-5.4.8.tar.gz
#cd php-5.4.8.tar.gz
# ./configure --prefix=/usr/local/lamp/php --with-apxs2=/usr/local/lamp/apache/bin/apxs \--with-mysql=/usr/local/lamp/mysql/
#make
#make install
#cp /usr/local/src/lamp/php-5.4.8/php.ini-production /usr/local/lamp/php/lib/php.ini
To Check the php module is installed properly
# /usr/local/lamp/apache/bin/apachectl -t -D DUMP_MODULES | grep php
Tell apache to process file starting .php extension
Open up the file "/usr/local/lamp/apache/conf/httpd.conf " then add " AddHandler application/x-httpd-php .php " with in the <IfModule mime_module> ....... </IfModule>
# vim /usr/local/lamp/apache/conf/httpd.conf
........................
<IfModule mime_module>
........................
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddHandler application/x-httpd-php .php .html
.........................
</IfModule>
# vim /usr/local/lamp/apache/htdocs/index.php
<?php
phpinfo ();
?>
:wq
# service httpd restart
# service mysqld restart
open up a browser and type http://127.0.0.1/index.php
#/usr/local/lamp/mysql/bin/mysql
#ln -s /usr/local/lamp/mysql/bin/mysql /usr/bin/mysql
Comments
Post a Comment