Simple Compile and install Apache2

Source: Internet
Author: User


CentOS system software Management mainly has three ways, Rpm,yum, as well as direct source management, the previous detailed introduction of RPM and the relevant usage of Yum, as operations personnel, source installation is sometimes unavoidable, below, we take Apache as an example of a simple introduction to the compilation installation.

First, what is the compilation installation

    • Compile: Change the source code to a machine executable code file.

    • Install: Installs the executable file in the operating system.

Second, why to compile the installation

    • Some software, and can not be installed through such a package management system such as RPM, this need to download the source code compiled installation.

    • Compiling and installing can flexibly customize the software, choose what you need, and cancel what you don't need.

    • Optimized for specific hardware, a compiled installation can achieve better performance.

Iii. how to compile and install

1. Construct the compilation environment

Compile Tool chain tool:

TD style= "Margin:0px;padding:.75pt;font-size:12px;font-family:verdana, ' song Body ', sans-serif;line-height:18px;" >


Brief introduction

< P style= "margin:6pt 0in;border:0px;list-style:none;" >binutils

< P style= "margin:6pt 0in;border:0px;list-style:none;" >GCC


C Library, providing standard routines (C function )

The above tools can be installed with yum install

2. Get the source code

    • Official self-built site: (ASF)


    • Code hosting:



3. Construct makefile file according to source code
650) this.width=650; "src=" Http:// "title=" Makefile.png "width=" 726 "height=" 388 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:726px;height:388px; "alt=" Wkiom1z-ndpttrwvaacd_v34bhg060.png "/>

Is the main step in generating the makefile file, and sometimes we may need to construct the configure with autoconf, and the Autoconf tool can be installed with Yum.

4. Install the software into the system using make and do install

The main uses of Make tools :

make You can also

TD style= "Margin:0px;padding:.75pt;font-size:12px;font-family:verdana, ' song Body ', sans-serif;line-height:18px;" > TD style= "Margin:0px;padding:.75pt;font-size:12px;font-family:verdana, ' song Body ', sans-serif;line-height:18px;" >
< P style= "margin:6pt 0in;border:0px;list-style:none;" > target

< P style= "margin:6pt 0in;border:0px;list-style:none;" >make all

< P style= "margin:6pt 0in;border:0px;list-style:none;" >make clean

Clear compilation result

< P style= "margin:6pt 0in;border:0px;list-style:none;" >make Distclean

configure The resulting  makefile   clear off

< P style= "margin:6pt 0in;border:0px;list-style:none;" >make install

< P style= "margin:6pt 0in;border:0px;list-style:none;" >make Dist

Make Distcheck

Packaging and testing

Iv. simple compile and install httpd

1. Get the source code


650) this.width=650; "src=" Http:// "title=" Download httpd source. png "alt=" Wkiom1z_ob_dz9wzaaa8ab0u8lk597.png "width=" 736 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 " Style= "width:736px;height:128px;"/> Through the wget command to the official website recommended mirror download, you can get to. tar.bz2 or the. tar.gz end of the source package

2. Prepare for compilation

    • Unzip the source package

Tar xvf httpd-2.2.31.tar.bz2

650) this.width=650; "src=" Http:// "title=" Tar decompression. jpg "width=" 759 "height=" 122 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:759px;height:122px; "alt=" wkiol1z_ R7nqvmngaahyalqojqi020.jpg "/>

The "Tar XF" command can be extracted from the source package according to the corresponding suffix name of the source package, into the extracted source package, we can see that there are already ready-made configure and files.

    • View Installation Manuals

650) this.width=650; "src=" Http:// "title=" Install.png "width=" 742 "height=" 229 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:742PX;HEIGHT:229PX; "alt=" WKioL1Z _pxfbaie-aaaqyemrpto985.png "/> Source package before the installation recommended to look at the install and the Readme file, such as the httpd of the extracted directory under the install file will tell us the basic steps to compile and install.

    • Read./configure--help Help

650) this.width=650; "src=" Http:// "title=" Configure file. jpg "width=" 735 "height=" 518 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:518px; "alt=" Wkiom1z_qaxqyu95aavaxa6kwdm541.jpg "/>

As you can see, through the./configure--help you can learn about the detailed compilation options, such as the ability to modify the installation location of the software through--prefix, or to point to the software that you need to rely on by--with-pcre=path. However, compiling Apache2 is generally simple and does not introduce many other options.

3. Start compiling


650) this.width=650; "src=" Http:// "title=" Generate Makefile.jpg "width=" 754 "height=" 126 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:754px;height:126px; "alt=" Wkiol1z_sizho4t0aaivukivthu038.jpg "/> here, only add--prefix option to configure to modify the software installation location, you can see that the makefile file has been successfully generated.

4. Generate the intended target and install to the system

Make && make install

650) this.width=650; "src=" "title=" make &&make install.jpg "width=" 754 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:754PX;HEIGHT:66PX; " alt= "Wkiol1z_shtsmyuiaadmpdec98c263.jpg"/>

Use the Make tool to complete this step, and of course you can also write a two-point command to do and do install. You can see that the APACHE2 related packages have been installed on the location specified in the--prefix option.

5. Start httpd, check the installation status

[Email protected] bin]# Cd/usr/apache2/bin[[email protected] bin]#./httpd-k start[[email protected] bin]# curl-i Loca Lhost:80

650) this.width=650; "src=" Http:// "title=" Start Httpd.jpg "width=" 762 "height=" 217 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:762PX;HEIGHT:217PX; "alt=" WKiom1Z _uquizpx3aairchisu6q822.jpg "/>

As you can see, the HTTPD service is running, indicating that the installation was successful.

Simple compilation of source code is easy to install, but to compile an efficient package to meet their needs, this often requires some work experience to assist. At this point, the package management of the Rpm,yum and source installation is finished.

Attached: If you have questions about the above description, look forward to discussing with your friends. I qq:1084569767

This article is from the "home of small Mosquitoes" blog, be sure to keep this source

Simple Compile and install Apache2

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: 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.