Introduced
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
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:
Tools |
Brief introduction |
< P style= "margin:6pt 0in;border:0px;list-style:none;" >binutils | 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;" >GCC |
|
glibc |
C Library, providing standard routines (C function ) |
The above tools can be installed with yum install
2. Get the source code
apache.org (ASF)
mariadb.org
...
SourceForge
github.com
code.google.com
...
3. Construct makefile file according to source code
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/84/wKiom1Z-ndPTTRWVAACD_v34BHg060.png "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
< P style= "margin:6pt 0in;border:0px;list-style:none;" > target |
|
< P style= "margin:6pt 0in;border:0px;list-style:none;" >make all | 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;" >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 | TD style= "Margin:0px;padding:.75pt;font-size:12px;font-family:verdana, ' song Body ', sans-serif;line-height:18px;" >
Make Distcheck |
Packaging and testing |
Iv. simple compile and install httpd
1. Get the source code
wget http://apache.dataguru.cn/httpd/httpd-2.2.31.tar.bz2
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/78/87/wKiom1Z_OB_DZ9wZAAA8Ab0u8Lk597.png "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
Tar xvf httpd-2.2.31.tar.bz2
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/78/86/wKioL1Z_R7nQVmNGAAHyalqojqI020.jpg "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 makefile.in files.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/78/86/wKioL1Z_PXfBaIe-AAAqyEmRPto985.png "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.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/87/wKiom1Z_QaXQyU95AAVAxA6kWDM541.jpg "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
./configure--prefix=/usr/apache2
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/78/86/wKioL1Z_SIzho4T0AAIvUkiVthU038.jpg "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=" http://s2.51cto.com/wyfs02/M00/78/86/wKioL1Z_ShTSMYuIAADMPdEC98c263.jpg "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://s4.51cto.com/wyfs02/M02/78/87/wKiom1Z_UQuizPX3AAIrcHIsU6Q822.jpg "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 http://timber.blog.51cto.com/7677013/1728724
Simple Compile and install Apache2