Saturday, May 23, 2015

Source Code Installation of Apache Web Server On Linux

In-order to get the true satisfaction, trill and software freedom from Linux , let's install Apache web server from source code on Linux Platform

These installation conducted with up-to date software packages and operating system as of 23rd May 2015. Any future changes to the installation process are not included.


Operating System used             - CentOS 6
Compatible Operating Systems - Fedora, RedHat Linux

Pre-installations and updates

1. Perform a full system update


   Login as root user
   Command : su
                      Enter password of root user and it gives you root shell
   Command : yum update


2. Install GNU C and C++ compilers

 
    Login as root user if not
    Command : yum install gcc*

3. Create a directory called LAMP in your preferred place.
 
     Command : mkdir LAMP

4. We are going to download all source codes into this location.
    Now change the present working directory to LAMP


    Command : cd LAMP

5. Download and extract apache web server source code from   

    http://httpd.apache.org/download.cgi

6. Extract it.

    Command : tar -xvzf httpd-2.4.12.tar.gz

7. Download and extract apache web server run time utilities from 
    https://apr.apache.org/download.cgi

   There are two libraries called APR and APR-Util.
   Extract them.


   Command : tar -xvzf apr-1.5.2.tar.gz
   Command : tar -xvzf apr-util-1.5.4.tar.gz


8. Move apr and apr-util folders in to srclib directory of apache server source code directory

   Command : mv apr-1.5.2 httpd-2.4.12/srclib/apr
   Command : mv apr-util-1.5.4 httpd-2.4.12/srclib/apr-util



9. Build the source code and install

     9.1. Login as root user if not
     9.2. Configure the source code, remember that --prefix= notation says the installation location


Command : ./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util

  It gave bellow build error due to dependency errors. "configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/". It may be different build error in your machine.You have to download dependent software and install it before you install apache. Some times dependent software may be depend on another new software. So you have to first find the dependency tree and then install all these dependencies.

Read the errors carefully and get the idea and search on the web

   9.3.1 Download pcre library source code and extract them to LAMP directory    
           
            Login as root user if not
            
            Extract source code
            Command : unzip pcre-8.37.zip
           
            Change current directory to your pcre-8.37
            Command : cd pcre-8.37
          

            Configure the source code
            Command : ./configure --prefix=/usr/local/pcre
           

            Build the source code
            Command : make

            Install it
            Command : make install

In my machine it gave bellow build error due to dependency issues "configure: error: mod_deflate has been requested but can not be built due to prerequisite failures"

Read the errors carefully and get the idea and search on the web

     9.3.2 Download zlib library source code and extract them to LAMP directory
          
             Login as root user if not

             Extract the source code
             Command : tar -xvzf zlib-1.2.8.tar.gz

             Change current directory to your zlib-1.2.8
             Command : cd zlib-1.2.8

             Configure the source code
             Command : ./configure --prefix=/usr/local/zlib

             Build the source code
             Command : make
            
             Install it
             Command : make install
  


10. Now reconfigure apache source code with mentioning newly installed dependencies

   Login as root user if not

   Change current directory to httpd-2.4.12
   Command : cd httpd-2.4.12
  
   Configure the source code
   Command : ./configure --prefix=/usr/local/apache --enable-so --enable-deflate --enable-headers --enable-rewrite --with-included-apr --with-included-apr-util --with-pcre=/usr/local/pcre/bin/pcre-config --with-z=/usr/local/zlib/
  
   Build the source code
   Command : make

   Install it
   Command : make install


11. If there are no errors then you have successfully installed apache web server from the source code.

12. Now change your directory to apache server location.

   Command : cd /usr/local/apache/bin

13. Start apache web server by bellow command

 Login as root user if not
 Command : ./apachectl start

14. Open your web browser and browse bellow url to check web server is working fine

 Command : http://localhost:80

15. If it shows we page with "It works!", 
      Then you have successfully installed apache web server.

16. Stop apache web server by bellow command
 
  Login as root user if not 
  Command : ./apachectl stop

17. Restart apache web server by bellow command

   Login as root user if not 
   Command : ./apachectl restart



Thank you.. Next we install MySQL and PHP from source code.

1 comment: