LAMP: Linux, Apache, MySQL, PHP for your Linux.

In the previous post, we already know about WAMP, a combination of Windows, Apache, MySQL and PHP, today I will introduce to you LAMP. In a same logic, LAMP stands for Linux, Apache, and MySQL and depending on who you talk to, the P also stands for Perl or Python, but in general, it is assumed to be PHP.

I run CentOS on my servers; the following directions were written for CentOS, of course, you can use it with a little modification on Red Hat, Fedora distribution.

Note: I’m prefer to build things from source, so, the below will not use any yum or apt-get

Let’s work immediately and build your LAMP.

Download the require package

Firstly, we need download some packages for installing. Here I will use the following packages:

  • Latest Apache HTTP Server, mine is httpd-2.2.8.tar.gz
  • Latest MySQL server, mine is mysql-5.0.51b.tar.gz
  • Latest PHP: mine is php-5.2.5.tar.gz

You can use “wget” command for download the packages required, run following command on your terminal:

 mkdir /home/user/sources
 cd /home/user/sources
 wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz/from/http:/mirrors.ircam.fr/pub/mysql/
 wget http://mirrors.24-7-solutions.net/pub/apache/httpd/httpd-2.2.8.tar.gz
 wget http://vn.php.net/distributions/php-5.2.5.tar.gz

Setting up MySQL

The basic commands that you must execute to install and use a MySQL binary distribution are:

Add a login user and group for mysqld to run as:

/sbin/groupadd mysql
/sbin/useradd –g mysql mysql

Uncompress downloaded MySQL package and install

tar –vxzf mysql-5.0.51b.tar.gz
cd mysql-5.0.51b
./configure --prefix=/usr/local/mysql
make
make install
cp support-files/my-medium.cnf /etc/my.cnf

Create the MySQL data directory and initialize the grant tables

cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
ls –l
After done, you will got the following screen:
 MySQL Directories Permission
Run mysql
./bin/mysqld_safe --user=mysql &

Starting mysqld daemon with databases from /usr/local/mysql/var  

cd /usr/local/mysql/bin/
./mysql

You will see

Welcome to the MySQL monitor. Commands end with; or \g.
Your MySQL connection id is 2 Server version: 5.0.51b-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit;

DONE, you are successfully installing MySQL on your Linux, next step is optional, and you can safely to skip.

Auto-start mysqld when system boot
cd /home/user/sources/mysql-5.0.51b
cp ./support-files/mysql.server /etc/init.d/mysqld
cd /etc/init.d
chmod 755 ./mysqld
cd /sbin
./service mysqld status
./chkconfig --add mysqld
./chkconfig --level 345 mysqld on

Setup Apache

Uncompress package and install

tar –xvzf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --enable-so --enable-dav --prefix=/usr/local/apache
make
make install
/usr/local/apache/bin/apachectl start

Auto-start apache when system boot

vi /etc/rc.d/init.d/rc.local

 

Add following line to your rc.local file.

/usr/local/apache/bin/apachectl start

Save and close, then restart your Apache

Next step, oops, we’re done, no more step is required, open your browser and try: http://localhost/

You will see the below screen

 Apache Installation Completed

Install PHP:

1.    Uncompress package and install

tar -xvzf php-5.2.5.tar.gz
cd php-5.2.5
./configure --prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql
make && make test
make install
cp php.ini-dist /usr/local/lib/php.ini
cd /usr/local/apache/conf
vi httpd.conf

Add following lines to your httpd.conf

 
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .phtml .htm

2. Restart and test your PHP installation

Restart apache
/usr/local/apache/bin/apachectl restart
 Create index.php file and save that file on Apache’s DocumentRoot (here DocumentRoot is /usr/local/apache/htdoc) with the following content:
 
<?php
phpinfo();
You can configure  Apache’s DocumentRoot at file httpd.conf

Open http://localhost/index.php on your browser

 PHP info

Comments

LAMP

.. good thing it is very updated..
I will try this step. hope it'll work. :)