Marco Linux Learning notes: source code compilation installation

Source: Internet
Author: User

As the RPM package in the author's production package has already fixed some of the characteristics of the program, if we need to use some of the program's non-universal related features, we need to download the source code to manually compile the installation, here is just a simple introduction of C code package compilation installation method.

In order to be able to see the source code to compile the installation process more intuitively, I demonstrated the compile installs the httpd2.2 in the centos7.2 environment:

First of all, the premise of the compiler is to have the tools and environment called hand, compile C source code needs to use the development tools, MAKE,GCC, the environment needs to develop the library somersault files, if the system does not have these, it needs yum installed.

Here I run the Yum Group install Development Tools Install development environment Component

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang /zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650; " Src= "Http://s5.51cto.com/wyfs02/M00/78/7D/wKioL1Z-JmvTGPHwAAHRR9I1I-4724.jpg" title= "1.jpg" alt= " Wkiol1z-jmvtgphwaahrr9i1i-4724.jpg "/>

After installing the development environment, start extracting the downloaded httpd-2.2.29.tar.bz2 and switch to the httpd-2.2.29 directory

[email protected] test]# tar-jxf httpd-2.2.29.tar.bz2

[[email protected] test]# ls

httpd-2.2.29 httpd-2.2.29.tar.bz2

[email protected] test]# CD httpd-2.2.29

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m01/78/7e/wkiom1z-jmtgpmjdaagdgexuwvu779.jpg "title=" 2.jpg "alt=" Wkiom1z-jmtgpmjdaagdgexuwvu779.jpg "/>

Now we can start compiling the httpd2.2.29, we can first look at the directory of the Readme,install file, you can get a preliminary look at some of the software and its general installation method of compiling:

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/78/7d/wkiol1z-jobammp9aajqrxfo5ry849.jpg "title=" 3.jpg "alt=" Wkiol1z-jobammp9aajqrxfo5ry849.jpg "/>

Execute./configure-h can look at the help of the Configure script first, look at some of the software installation options, different software configure vary, but generally have the following features:

1. Specify the installation path

--prefix= prefix for specifying the installation path

--sysconfdir=/etc/package_name

2. Specify the Startup/disable feature

--enable-feature: for example--ENABLE-FPM

--disable-fecture; for example--disable-socket

3. Specify which features, programs, or files you rely on

--with-function: Enable a feature

--without-function: Disabling a feature

Here we simply specify the httpd installation path, if there is a special need, please refer to the Configure Help information, add or turn off the software features yourself.

Note that because this is only a test, I installed the service into the root of the home directory, to run the service and allow the external host to access the home directory needs to give RX permissions to root, production environment is not recommended to do so, try to install to/usr/local/and other directories, remember!

[email protected] httpd-2.2.29]#/configure--prefix=/root/test/httpd2.2

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m00/78/7e/wkiom1z-jpzgrgjeaagpapeh_sg078.jpg "title=" 4.jpg "alt=" WKiom1Z-JpzgRGjEAAGpaPEH _sg078.jpg "/>

[[email protected] httpd-2.2.29]# make && make install

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang /zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650) this.width=650; " Src= "Http://s4.51cto.com/wyfs02/M00/78/7D/wKioL1Z-JsihX1PqAAD8RJJck-k416.jpg" title= "5.jpg" alt= " Wkiol1z-jsihx1pqaad8rjjck-k416.jpg "/>

At this point, the compilation and installation of httpd2.2 has been completed, it is so simple, quickly try to do wow. We start by manually compiling the installed httpd to see WOW:

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m01/78/7d/wkiol1z-jtvgsuadaaf2cp9dd7a920.jpg "title=" 6.jpg "alt=" Wkiol1z-jtvgsuadaaf2cp9dd7a920.jpg "/>

You can see that the compiled installation of the HTTPD service has started to work, but it seems to start up a good trouble, you have to switch to the directory installed in the bin directory, if you can directly in the command line under any path can be managed to start or shut down, this is our compilation after the installation of some follow-up work:

1. Export the binary program directory to the PATH environment variable;

Edit the file/etc/profile.d/httpd2.2.sh file, write the bottom line in the file; (Note that the httpd2.2.sh file does not exist, create it)

Export Path=/root/test/httpd2.2/bin

Save exit, for this setting to take effect immediately, you need to execute the command in the current directory

SOURCE httpd2.2.sh

Now we can open or close the HTTPD service under any path in the system, instead of remembering the long list of paths.

2. Export the library file path;

Editor/etc/ld.so.conf.d/httpd2.2.conf; Note: The httpd2.2 file does not exist and you need to create it yourself

Add a new library file in the same directory as this file;

/root/test/httpd2.2/lib

To have the system regenerate the cache:

Ldconfig [-v]

-V View Details

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s5.51cto.com/wyfs02/m01/78/7e/wkiom1z-juralmyzaagks4bga-g423.jpg "title=" 7.jpg "alt=" Wkiom1z-juralmyzaagks4bga-g423.jpg "/>

3. Export Header file

Implemented in a link-based manner:

ln-sv/root/test/httpd2.2/include/usr/include/httpd2.2

4. Export Help Manual

Edit/etc/man_db.conf file, add a manpath; Note: The/etc/man.config file is in the centos6.x series

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/78/7e/wkiom1z-jviazox0aafvfrpy9as195.jpg "title=" 8.jpg "alt=" Wkiom1z-jviazox0aafvfrpy9as195.jpg "/>

Mans Apachectl

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m01/78/7e/wkiom1z-jwyjk-ebaanhedqiydi282.jpg "title=" 9.jpg "alt=" Wkiom1z-jwyjk-ebaanhedqiydi282.jpg "/>

At this point, the compilation and installation of the work is finished, try to get started!


This article is from the "Amengmon" blog, make sure to keep this source http://amengmon.blog.51cto.com/10985711/1728544

Marco Linux Learning notes: source code compilation installation

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.