Monday, April 29, 2013

Have you ever tried installing Apache 2.4.4 in Linux.?

Hello Guys,

Just for sometime I was away from my blogging, but recently had to touch the pages for self signed certs in WebLogic Server on one of my friends request, hoping to get the blogging on the track from now.

Today I tried to install Apache Web Server in Linux Environment, it may sound silly thing however you may need to know few of the things while you get your arms ready when you work with Apache Web Server Administration.

I found that you may face few of the difficulties while you install Apache Web Server in Linux Environment, common ones are : Steps to Install, Supporting Libraries and Any Utilities required for install to be successful.

Well.. Steps.!!

Step 1. Download the Apache WebServer

Click the link here or visit site : http://httpd.apache.org/ for downloading the binaries for different operating system

Step 2. Save it in a safe location and Unzip and Untar it.

Move it to your required location and unzip and untar it as you have tar.gz file.

#mv httpd-2.4.4.tar.gz /labs 
#cd /labs
#gunzip httpd-2.4.4.tar.gz
#tar -xvf httpd-2.4.4.tar

you will see huge number of lines showing the extracted files in the the directory called httpd-2.4.4, with this you have extracted the tar'ed files into httpd-2.4.4 directory.

Step 3. Install it

#cd httpd-2.4.4
#./configure --prefix=/labs/apache2.4.4
#make
#make install

Well, this looks simple but is not..!!

The steps for installing are very simple, you just need follow below 3 commands and you are done, however you may need to make the operating system understand that you are installing the Apache WebServer for that you might need APR, APR-UTIL and PCRE binaries to be installed before Apache Web Server, failing which you will see the below error messages.

while you are running the first command above you will get to see the below error messages each for above 3 modules.

I am setting the prefix for install path for the apache webserver.

If you do not have APR (Apache Portable Runtime) installed prior to Apache Install, you will see : 

checking for APR … no 
configure error APR not found. please read the documentation 

This can be fixed by installing APR from the link : http://apr.apache.org/ and download the latest tar file, gunzip, untar and then install the binary as below.

NOTE : We may need to install the APR same way we do for HTTPD Server ( Apache Web Server)

# cd apr-1.4.6
# ./configure  (you can add --prefix to supply the install path, it will install in     /usr/local/ if not specified)
#make
#make install

Now try running Apache configure and see the difference, however this time you need to pass one more argument with ./configure command as below.

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr

This doesn't show error which occurred before, but turns in to a new error as below.

checking for apr-util … no 
configure error apr-util not found. please read the documentation

Well for this you need to follow the same steps you have done for APR, you need to visit the same site and download the apr-util file.


This time while you are installing the apr-util you need to run the below command after extracting the file.

#cd apr-util-1.5.2
#./configure --prefix=/usr/local/apr-util/  --with-apr=/usr/local/apr/
#make
#make install

This will create a one more directory under /usr/local as apr-util

Now try to Run Apache Install, but with a brand new command.

#./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

This command will by pass both of the above errors, but we are not done yet..!!, You will see below error while trying to execute the above command.

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

We need one more library called PCRE (Perl Compatible Regular Expression) which is used by our httpd server, download it from  http://pcre.org/ - move it your Linux/Unix Filesystem and gunzip and untar it.

You can go ahead and install this library without any dependency on APR or apr-util, you can use the below commands to install PCRE.

#./configure --prefix=/usr/local/pcre
#make
#make install

Once you are done, now its the turn of Apache Server finally with below command.

#cd httpd-2.4.4
#./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre#make
#make install
:
 /usr/local/apr/build-1/libtool --silent --mode=install install mod_env.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_expires.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_headers.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_unique_id.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_setenvif.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_version.la /usr/local/apache2/modules/
/usr/local/apr/build-1/libtool --silent --mode=install install mod_remoteip.la /usr/local/apache2/modules/


:
 

Installing configuration files
mkdir /usr/local/apache2/conf
mkdir /usr/local/apache2/conf/extra
mkdir /usr/local/apache2/conf/original
mkdir /usr/local/apache2/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2/htdocs
Installing error documents
mkdir /usr/local/apache2/error
Installing icons
mkdir /usr/local/apache2/icons
mkdir /usr/local/apache2/logs
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
mkdir /usr/local/apache2/include
Installing build system files
mkdir /usr/local/apache2/build
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: Leaving directory `/labs/httpd-2.4.4'


Done with installation, now if you would like to verify whether your httpd server is working fine or not.

#cd /usr/local/apache2/bin
#apachectl status
#apachectl start

You can verify the httpd processes running by using ps -ef | grep httpd then you will see around 3-4 processes running in the console.

Access the URL : http://localhost/ -- you will see the text saying : It works! on the browser.

Well.. I hope this post will help you a bit with getting track of Apache Web Server install in Linux Operating System.

Thank you..

Regards
Shailesh Dyade.

2 comments:

K@mal said...

Hi Shailesh,

I am facing an issue while i am trying to configure APR. I get error "configure:5350: error: no acceptable C compiler found in $PATH" but when i check on the linux box i see that GCC that is required for compliation of the APR is existing

#########
[root@************]# whereis gcc
gcc: /usr/libexec/gcc
#####################

ERROR
##############################
configure:4580: checking build system type
configure:4594: result: x86_64-unknown-linux-gnu
configure:4614: checking host system type
configure:4627: result: x86_64-unknown-linux-gnu
configure:4647: checking target system type
configure:4660: result: x86_64-unknown-linux-gnu
configure:4723: checking for working mkdir -p
configure:4739: result: yes
configure:4831: checking for chosen layout
configure:4833: result: apr
configure:5098: checking for gcc
configure:5128: result: no
configure:5191: checking for cc
configure:5238: result: no
configure:5294: checking for cl.exe
configure:5324: result: no
configure:5348: error: in `/opt/apache/httpd/********/apr/apr-1.4.6':
configure:5350: error: no acceptable C compiler found in $PATH
See `config.log' for more details

#######################

Could you please suggest how can i fix this issue.

Raj Kiran said...

hello Kamal,
I feel like your gcc compiler is either corrupted or Ur Linux path is not correct.Two things which u can do it,

1)You can reinstall the gcc package by YUM method..Please note that this requires Linux repository to be created.

2)U can add the path of ur GCC to PATH variable in /etc/profile and source it,following u can have a try.

Tks
Raj