LAMP Installation and Configuration form Source Code | Free VPS

4:11:00 AM 0


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://in1.php.net/get/php-5.4.8.tar.gz/from/this/mirror
                    

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
   
       Now open your Browser and type http://Yourip  or http://masterdns.shyam.com
       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!

       Now open your Browser and type   http://Yourip/phpinfo.php  or http://masterdns.shyam.com/phpinfo.php
       You will get test page containing information about php, mysql, apache and all the libraries compiled with php.





                                                                        .�������������������.
                                                                        �.������������������.
                                                                        �������������������..

                                                                        �������������������..

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






Linux Basic Command and Options with Example  | Free VPS

Linux Basic Command and Options with Example | Free VPS

8:09:00 AM 0

1.Shell :
            Operating system to User intermediate

            #cat /etc/shells
                 /bin/sh         => Shell
                 /bin/bash     => Bourn Again Shell
                 /bin/tcsh      =>
                 /bin/csh        => C Shell
                 /bin/nologin   =>  NoLogin shell

2. Kernel :
            Hardware to Operating system monitoring

3. [Root@Server6 ~]#  or $ :

            Root        => Indicate to which User
            Server6   => Indicate to Hostname
            ~    => Indicate to Home Directory
            #    => Indicate to Root Privilege
            $     => Indicate to Normal User Privilege

4. F.S.H  ( File System Hierarchy ) :

            /root     => Root Home Directory
            /boot    => Only stored Boot files
            /home  => Normal users Home Directory
            /bin       => Stored in Binary files or Executions files
            /lib        => Library files or Documentations
            /etc       => All Configuration files stored in this directory
            /var       => Variable Directory. Used to share the contents ( FTP, HTTP�)
            /mnt     => Used to default mount point for Disk Partitions
            /media => Mount Point for External Devices ( CD/DVD, USB, Pendrive�)

5. Help and Information for Commands :

            MAN  =>  Format and Display online manual copy.
                 # man ls        
                 # man mkdir

            INFO  =>  Read full Documentations.
                 # info ls
                 # info cd

            PINFO  =>  Small Graphical Page.
                 # pinfo ls
                 # pinfo cd

            --HELP or  -?   =>  Small Information.
                 # ls �help
                 # ls -?

            WEBPAGE  =>  It display webpage Documentations.
                  File:///usr/share/doc

6.  LS Command :

            Options :       -l => Long List
    -a => Display All Files.
    -d => Display Present Directory Information
    -h => Human Readable.
    -f  => Display File Type.
    -R => Display sub directory to recurs.
            # ls �alh
            # ls �R
            # ls �d .

7.  PWD Command : ( Present Working Directory )

            # pwd
               /root.

8.  WHOAMI Command :  ( To identify which user login for Terminal)

            # whoami                   # whoami
               Root.                           Shyam.

9.  LOGNAME Command : (The real user who logs in initially)

            # logname                      # su - shyam
               Root.                             # logname
             # whoami                         Root.
                root                              $ whoami
                                                          shyam

10.  HOSTNAME Command : ( to check the computer name )

            # hostname
               Server6.


11.  UNAME Command : (to check  OS, Version, Architecture, Hostname etc..)

            Options  :  -a, -s, -n, -r, -v, -m, -p, -I, -o
           
            # uname
               Linux.
            #uname �a  ( all )
              Linux server6.example.com 2-6.32-131.0.15.el6.x86_64 ��������
           
12.  CD Command : ( to use Change Directory )

            # cd       => go to home directory
            #cd ~     => go to home directory
            # cd /var/www/html/       => go to html directory
            #cd ..                         =>  back to one directory
            #cd -                          => forword to directory

13   ID Command : ( Identification, to check UID and GID )

            # id
               Uid=0(root) gid=0(root)  groups=0(root)
            # id shyam
               Uid=500(shyam) gid=500(shyam) groups=500(shyam)

14.   TTY Command : (Psuedo Terminal, to check the user login and terminal)

            Terminal 0 :
            # tty
              /dev/pts/0

            Terminal 1 :
            #tty
              /dev/pts/1

15.   CLEAR Command : ( to clear the terminal screen )

            # clear

16.   DATE Command : ( Display the Date and Time )

            # date     => to display date and time
            # date �s   2011-12-05  => change only date
            # date �s   5:30:20         =>  change only time

17. CAL Command : ( Display the Calendar )

            # cal    => to display current month
            # cal 2011  => to display 2011 an all month
            # cal 12 2011   => to display month 12, year2011


18.   WHICH Command : ( Show the full path of commands/shell)

            # which ls
               /bin/ls
            #which  chown
              /bin/chown

19.   WHATIS Command : ( Search the full database for complete words )

            # whatis w
              Who is logged on and what they are doing
            #whatis ls

20.   WHEREIS Command : ( Locate the Binary, Source, Manual page for all commands)

            # whereis ls
               Ls: /bin/ls   /usr/share/man/ma1/ls.1.gz   /usr/share/man/man1p/ls.lp.gz

21.   WALL Command : ( Broadcast on the message send to all logged in user on the system)

            # wall
               Hai Pls reboot.  => type the msg.

            CTRL + D   => Exit

22.   WC Command : ( Word Count, word counting cmd)

            Options  :   -l => line count ,    -w => word count,     -c => byte count,     -m => character count
            # wc �l /etc/passwd
            # ls | wc �l

23.  TOUCH Command :  ( to create Empty File or 0byte file )

            # touch file1
            # touch /home/shyam/shyam.txt
            # touch file{1..5}.txt
            # touch file1 file2 file3 file4 file5

24.   CAT Command :  ( Canonical system )

            # cat file1 => show the file1
            # cat > newfile1.txt             => create new file.
            # cat >> newfile1.txt          => overwrite new content

25.  HISTORY Command : ( to shows the all typed commands )

            # history
            # ! serv                     => to run service httpd restart
            # !55                          => to run 55 command

26.   MKDIR Command : ( Make Directory )
           
            # mkdir test            => create directory under the PWD
            # mkdir /var/www/html/pc1.linux.com/   => create to directory under the html.

27.   MORE Command : ( It shows small paragraph )

            # more /etc/httpd/conf/httpd
            #more /etc/passwd

28.   LESS Command : ( it display simple method, scrolling function available)

            # less /etc/httpd/conf/httpd
            # less /etc/passwd

29.   HEAD Command : ( it shows 1stfew lines of the text, By default 10 line )

            # head /etc/passwd           => By default 1st 10 line
            # head -5 /etc/passwd      => to display 1st 5 lines
            # head -20 /etc/passwd => to display 1st 20 lines

30.    TAIL Command : ( it display last few lines of text, By default last 10 line )

            # tail /etc/passwd                => By default last 10 lines
            # tail -15 /etc/passwd        => to display last 15 lines
           
            # tailf /var/log/httpd/access_log   => view log files while it is being updates

31.    UNIQ Command : ( Identify any duplicate line entries in a file or input provider )
           
            Options  :  -d , -i
            # vim shyam.txt  => type any content
            # uniq shyam.txt =. To check

32.    STRING Command : (Find and Display legible information embedded within a non-text or binary file)

            # string /bin/cat
            # string /bin/mkdir

33.    CP Command : ( Copy File, Copy the file/Directory one location to another location as same copy )
           
            Options  :  -I, -r, -p
            # cp shyam.txt   shyam.txt.back  => take the copy and change the name
            # cp shyam.txt   /var/ftp/pub/shyam.txt  => copy to another location
            # cp /root/shyam.txt   /var/ftp/pub/shyam.txt  => same as above, it is another method
            # cp �I /root/abc.txt   /tmp/abc.txt  => copy time ask Yes or No
            # cp �p /root /abc.tcxt   /tmp/abc.txt  => permission, time, ownership copy to same
            # cp /root/*   /tmp/  =>  copy all
            # cp /root/.txt  /tmp/  => only copy .txt contents
            # cp �r /root/*   /tmp/  => copy at recursive  

34.   MV Command : ( Used to Move / Rename the file or directory )

            # mv /root/shyam.txt   /root/aaa.txt  => rename the file
            # mv /root/shyam.txt   /var/ftp/pub/shyam.txt  => move the file to another location

35.   RF Command : ( Remove the File / Directory )

            Option  :  -f => Force,    -r => Recursive
            # rm shyam.txt  => Remove the file
            # rm �f shyam.txt => Remove the file forcibly
            # rm �r shyam.txt => Remove the file and ask the Yes or No
            # rm �rf shyam.txt  => Forcibly removing

36.   STAT Command : ( File/Directory Statistics or Properties)

            # stat /root
            # stat/root/shyam.txt

37.   File / Directory Attribute Settings :

            lsattr  => Listing ,     chattr  => Modifying    ( + set the value,   - Unset the value )

            Options  :  -a, -i,�.
            # lsattr /root/shyam.txt
               -----------e- shyam.txt

            #chattr +ia shyam.txt
               ------ia----e- shyam.txt

#chattr -ia shyam.txt
               ------ia----e- shyam.txt

38.   Pattern Matching : GREP  ( Global Regular Expression Print )

            # grep �shyam� /etc/passwd
               Shyam:X:500:500: :/home/shyam:/bin/bash

            # grep �shyam� - -color /etc/passwd            
           

            # grep �root� /etc/passwd  /etc/shadow
               /etc/passwd => root:X:0:0:root:/bin/bash
              /etc/shadow => root: :15253:0:9999:7: : :

            # grep ^root /etc/passwd  => ( to display startins word for root all entries )

            # grep bash$ /etc/passwd  => ( to display last word or sentence )

            # grep ^root$ /etc/passwd

            # grep �i shyam /etc/passwd  => ( to ignore all letters)

            # cut �f2 �d � : � /etc/shadow       
            # grep �shyam� /etc/shadow
            # grep �shyam� /etc/shadow | cut �f2 �d � : �

39.   Symbols :

     => Overwrite the file�s
>>      => Appending the file�s
|        => Pipe
&&    => AND Option 1st is true then go to 2nd option
||      => OR any one condition is true

40.    USER Administration :

            UID :  0 => root,     1 to 499 => System Services,      500 above => Normal Users
           
           User Account file and Directory :
            /etc/passwd,    /etc/shadow,    /etc/groups,    /etc/gshadow,    /home/users,    /var/mail

1.       /etc/passwd :  user1: X: 500: 500: Regular Comments: /home/user1: /bin/bash
User 1                  => User name
X                            => Password place holder
500:500               => UID and GID
Comments        =>  Use any Comments, Hai welcome etc�
/home/user1   => User Home Directory
/bin/bahs           => User Shell
        
2.       /etc/shadow :  user1: $6$BY$JKJJ9789N�: 15265: 0: 99999: 7:  :  :
User1                   => User name
$6$jhvjh�.         => Encrypted Password
15265                   => Last changes day ( Epoch time Jan 01 1970 )
0                                           => Minimum days
99999                   => Maximum days
7                            => Warning days
:                             => Inactive days
:                             => Disabled day
:                             => Feature use

3.       /etc/group  :   user1: X: 500:  :
User                     => User name
X                            => Password place holder ( /etc/gshadow)
500                        => GID (Privet GID )
:                             => Group members


42.   USERADD Command :  ( Add a new user )

         Option :      -c => Comments
                                -o => non-unique (  to use duplicate UID in normal user )
                                -u => UID ( we have to prefer UID )
                                -s => Shell ( to change shell )
                                - r => system account ( to use system service accounts )
                                -g => GID ( to use duplicate GID in normal users )
                                -e => Expire date ( given to the account expire date )
                                -p => Password ( given to the Encrypted password )
                                -d => Home Directory ( change to home directory)          
         # useradd user1  => Normal creation
         # userad  �c Hai  �o  �u 605  �s /bin/csh user2  => Add Comments, UID, Shell
         # useradd �r user3  => Encrypted Password
         # useradd  �g 700   -e 2011-11-01  -d  /var/www/html/user4  user4  => Add GID, Expir date, Home                                                                                                                         directory
         # useradd  -s /sbin/nologin   user5  => Use nologin

         # passwd user1

1.       User Login Information :
# vim /etc/login.defs
2.       Default Useradd Functions :
# vim /etc/default/useradd