Install Apache 2 from source on Linux

Source: Internet
Author: User
Document directory
  • 1. Download Apache
  • 2. install Apache
  • 3. Start Apache and verify Installation
  • 4. Start Apache automatically during system startup

From http://www.thegeekstuff.com/2008/07/install-apache-2-from-source-on-linux/

All Linux distributions comes with Apache. however, it is recommended to Download latest Apache source code, compile and install on Linux. this will make it easier to Upgrade Apache on a ongoing basis immediately after a new patch or release is available for download from Apache. this article explains how to install apache2 from source on Linux.

1. Download Apache

Download the latest version from Apache HTTP Server project. Current stable release of Apache is 2.2.9. Move the source to/usr/local/src and extract it as shown below.

# cd /usr/local/src# gzip -d httpd-2.2.9.tar.gz# tar xvf httpd-2.2.9.tar

2. install Apache

View All configuration options available for Apache using. /configure-help (two hyphen in front of help ). the most commonly used option is-Prefix = {install-Dir-name} to install Apache on a user defined directory.

# cd httpd-2.2.9# ./configure --help

In the following example, Apache will be compiled and installed to the default location/usr/local/apache2 with the DSO capability. using the-enable-So option, you can load modules to Apache at runtime via the dynamic shared object (DSO) mechanic, rather than requiring a recompilation.

# ./configure --enable-so# make# make install

Note: During the./configure, you may get the following error message.

# ./configure --enable-soconfigure: error: no acceptable C compiler found in $PATHSee `config.log' for more details.configure failed for srclib/apr

Install the GCC and the dependent modules as shown below and try./configure again to fix the above issue.

# rpm -ivh gcc-4.1.2-14.el5.i386.rpm glibc-devel-2.5-18.i386.rpm glibc-headers-2.5-18.i386.rpm kernel-headers-2.6.18-53.el5.i386.rpmPreparing...                ########################################### [100%]1:kernel-headers         ########################################### [ 25%]2:glibc-headers          ########################################### [ 50%]3:glibc-devel            ########################################### [ 75%]4:gcc                    ########################################### [100%]

3. Start Apache and verify Installation

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

Go to http: // local-host, which shoshould display the default message "It works !"

4. Start Apache automatically during system startup

Modify the/etc/rc. d/init. d/httpd script and change apachectl and httpd variable to point to the appropriate new location as shown below. please note that this httpd script was originally installed as part of the default Apache from the Linux distribution.

apachectl=/usr/local/apache2/bin/apachectlhttpd=${HTTPD-/usr/local/apache2/bin/httpd}

Now, you can perform the following to stop and start the Apache

# service httpd stop# service httpd start

Setup the Apache to automatically startup during reboot as shown below.

# chkconfig --list httpdhttpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off# chkconfig --level 2345 httpd on# chkconfig --list httpdhttpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.