About LAMP :
LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP (it can be either python or perl). LAMP represents a full featured stack containing the most popular web server known as Apache. The most popular database server MySQL and the most popular open-source web programming language known as PHP. In This Documentation I will show you how can we install the LAMP stack from the source code.
Step � 1 Basic Configuration Checking.
1. To check the System Architecture.
2. To Check the Network Information (IP).
3. To check the Hostname for the LAMP Server.
4. To stop the IPtables and Check the Rules.
5. To check Selinux Enabled or Disabled.
Step � 2 LAMP Installations and Configuration.
Directory Structure of my Installation:
/usr/local/src/ => The Downloaded .tar file will be save here.
/usr/local/lamp/ => This where I compile install the source code.
/usr/local/lamp/apache => I will install Apache under this directory.
/usr/local/lamp/mysql => I will install MySQL under this directory.
/usr/local/lamp/php => I will install PHP under this directory.
Check and Remove if already installed RPM�s.
Change the directory and download the source code from internet.
[root@masterdns src]# wget http://apache.techartifact.com/mirror/httpd/httpd-2.2.22.tar.gz
[root@masterdns src]# wget http://in1.php.net/get/php-5.4.8.tar.gz/from/this/mirror
[root@masterdns src]# wget http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz/from/http://cdn.mysql.com/
Install Supported / Dependency packages. ( gcc, gcc-c++, make, cmake, ncurses, libxml2-delvel).
Compiling and Testing Apache-Server.
[root@masterdns src]# tar -xvf httpd-2.2.22.tar.gz
[root@masterdns src]# cd httpd-2.2.22
[root@masterdns httpd-2.2.22]# mkdir /usr/local/lamp
[root@masterdns httpd-2.2.22]# ./configure --prefix=/usr/local/lamp/apache --enable-so --enable-mods-shared="most"
[root@masterdns httpd-2.2.22]# make
[root@masterdns httpd-2.2.22]# make install
Note: What is Configure Script , Make, Make install :
Configure: Configure script Checks some details about the machine on which the software is going to be installed. This script checks for lots of dependencies on your system. For the particular software to work properly, it may be requiring a lot of things to be existing on your machine already. If any of the major requirements are missing on your system, the configure script would exit and you cannot proceed with the installation, until you get those required things. if configure fails we can not execute the make command.
Make: Actual Compilation of the source code
Make install: Install the compiled binaries to proper directories.
--prefix : With prefix we specify the location where want to install the software (/usr/local/lamp/apache/). Default location will be under (/usr/local/apache2)
--enable-so : This will enable DSO (Dynamic Shared Object ) capability so that we can add additional modules to apache without recompiling the entire apache.
--enable-mods-shared="most" :List of modules we want to enable . Here I choose to enable most of the modules.
Apache Directory structure.
Starting and Testing Apache.
After installation, we need to configure the �ServerName� point to localhost in httpd.conf file.
[root@masterdns apache]# vim conf/httpd.conf
ServerName masterdns.shyam.com:80
[root@masterdns apache]# bin/apachectl start
httpd (pid 13198) already running
Note: The default index.html is locate inside the /usr/local/lamp/apache/htdocs/index.html
Compiling and Testing MySQL-Server.
Before compiling the mysql we need to create a user called "mysql" so that we can run the mysql service under his privilege.
[root@masterdns src]# groupadd mysql
[root@masterdns src]# useradd -g mysql mysql
Extract the downloaded mysql source code and compile.
[root@masterdns src]# tar -xvf mysql-5.5.28.tar.gz
[root@masterdns src]# cd mysql-5.5.28
[root@masterdns mysql-5.5.28]# cmake --DCMAKE_INSTALL_PREFIX=/usr/local/lamp/mysql --DMYSQL_DATADIR=/usr/local/lamp/mysql/data
[root@masterdns mysql-5.5.28]# make
[root@masterdns mysql-5.5.28]# make install
Note:If you get any error while running the camke like any dependency error first you need to install the proper rpm and before running the cmake again you should remove CMakeCache.txt.
[root@masterdns mysql-5.5.28]# rm -rf CMakeCache.txt
If you installed mysql rpm already using rpm then you should go through this steps.
[root@masterdns mysql-5.5.28]# rm -rf /etc/my.cnf
[root@masterdns mysql-5.5.28]# chkconfig --del mysqld
Change the ownership for mysql directory.
[root@masterdns src]# chown -R mysql:mysql /usr/local/lamp/mysql/
Change to Mysql directory and see the directory content.
Set the MySQL Base Directory and Database Directory using mysql script.
Copy the MySQL configuration file to /etc/my.cnf
[root@masterdns mysql]# cp /usr/local/lamp/mysql/support-files/my-medium.cnf /etc/my.cnf
To add the MySQL service script to /etc/init.d/ directory and enable prenatally.
[root@masterdns mysql]# cp /usr/local/lamp/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@masterdns mysql]# chkconfig --add mysqld
[root@masterdns mysql]# chkconfig --level 235 mysqld on
[root@masterdns mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@masterdns mysql]# service mysqld restart
Shutting down MySQL. SUCCESS!
Starting MySQL... SUCCESS!
[root@masterdns mysql]# netstat -ntlp | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 29421/mysqld
Now we need to install MySQL Client package, then only we can access MySQL Server.
Now access MySQL Server using MySQL Client in terminal.
Compiling and Testing PHP
Compile the PHP source code with support with Apache and MySQL.
[root@masterdns src]# tar -xvf php-5.4.8.tar.gz
[root@masterdns src]# cd php-5.4.8
[root@masterdns php-5.4.8]# ./configure --prefix=/usr/local/lamp/php --with-apxs2=/usr/local/lamp/apache/bin/apxs --with-mysql=/usr/local/lamp/mysql/
[root@masterdns php-5.4.8]# make
[root@masterdns php-5.4.8]# make install
[root@masterdns php-5.4.8]# cp /usr/local/src/php-5.4.8/php.ini-production /usr/local/lamp/php/lib/php.ini
Checking php module is installed properly.
[root@masterdns php-5.4.8]# /usr/local/lamp/apache/bin/apachectl -t -D DUMP_MODULES | grep php
php5_module (shared)
Syntax OK
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>
[root@masterdns php-5.4.8]# 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>
Check Everything works properly.
Create an index.php under /usr/local/lamp/apache/htdocs/ with the following contents.
[root@masterdns src]# vim /usr/local/lamp/apache/htdocs/phpinfo.php
<?php
phpinfo();
?>
Now restart the all Services.
[root@masterdns src]# /usr/local/lamp/apache/bin/apachectl start
httpd (pid 13198) already running
[root@masterdns src]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL...... SUCCESS!
.�������������������.
�.������������������.
�������������������..
�������������������..
Making phpinfo.php as the default page.
Edit the/usr/local/lamp/apache/conf/httpd.conf as follows.
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Change to�..
<IfModule dir_module>
DirectoryIndex phpinfo.php index.html
</IfModule>
Removing the Installed LAMP server.
You can simply uninstall the lamp server by removing the directories in which you have installed the source code but before doing this you should properly stop the running services.
[root@masterdns ~]# /usr/local/lamp/apache/bin/apachectl stop
[root@masterdns ~]# service mysqld stop
[root@masterdns ~]# rm -rf /usr/local/lamp/apache
[root@masterdns ~]# rm -rf /usr/local/lamp/mysql
[root@masterdns ~]# rm -rf /usr/local/lamp/php
EmoticonEmoticon