./configure && make && make install详解

The most important thing to use the source package to install software in Linux is to carefully read the README INSTALL two instructions in the installation package, these two files will clearly tell you how to correctly complete the installation of this software!

          We all know that the source package installation is divided into several stages,
1. ./configure : "configure " will test the existing features on your system Make : compile the program.      
5.   cd: Enter into this source package.
 
Now ls the mrtg directory with a blue font httpd-2.2.11. This directory is the one we just unzipped, and then cd into this directory! If you do not enter this directory but directly ./configure , the following prompt will appear!
3, bug!) Then create a Makefile to complete make !
The "configure " script has a large number of command-line options, which may vary for different packages, but many basic options do not change. The one we use the most is the following command:
./configure --prefix=/path where the software is to be installed
But we can also directly ./configure without specifying the path. Usually, the default path of software compiled and installed from the source package is /usr/local/. If ./configure is unsuccessful and go directly to make, the following figure will appear. mistake:
When we solve the error of ./configure, and then re-./configure is successful, we can compile the program!
Let's talk about a few files that can be related to the success of the compilation: /etc/ld.so.conf, ldconfig
First of all, let's talk about /etc/ld.so.conf, the path of the dynamic link library used during compilation recorded in this file. By default, the compiler will only use the library files in the two directories of /lib and /usr/lib , if you have installed other libraries, then it is OK to write the absolute path in the library file in /etc/ld.so.conf after the installation is complete.
Let's take a look at what ldconfig is:
He is a program whose function is to cache the path in /etc/ld.so.conf to /etc/ld.so.cache, so after installing some library files or modifying ld.so.conf to add new ones After the path, you need to run /sbin/ldconfig to make all library files cached in ld.so.cache. If /sbin/ldconfig is not run, even if the library file is in /etc/ld.so.conf, it will not be It is used, and the result is that the XXX library is missing during the compilation process as well!
4. Make : Compile the program.
When compiling, there are differences between gcc versions, so sometimes different versions of gcc are used to compile, and some versions can be compiled successfully, while others fail to compile, such errors are only version problems.
In addition , another error that will appear when making is more difficult to deal with. When encountering such a problem, you can only find the reason based on experience. For example, a header file is not found. At this time, you should follow the error position line by line. Look up, such as showing XXXXXX.h...... no such file or directory , indicating that the header file is missing, or find valuable error information to search in the search engine, from here you may find useful information for you, the most The important thing is to read the README and INSTALL files carefully before installation . These two files will tell you how the program should be installed, what dependent files are needed, and so on.
Sometimes when compiling, you don't know whether the compilation is successful, and if you go to make install without compiling , you will definitely make an error, which increases the complexity of the problem. We can check for successful compilation with a command at the end of make : echo $?
After entering this command and press Enter, the output result is 0 , then it means that the compilation is successful, otherwise it is an error, echo $? means to check the exit status of the previous command, and the program exits normally and returns 0 !
5. Make install : Install the file!
It also reads instructions from the Makefile and installs to the specified location.
After seeing the output of 0 in the above figure, we can make install to install it. After running, enter echo $? to check if there are any errors. As long as the output result is 0 , it means that our installation is successful. We can test it and put Apache 's service starts /usr/local/apache2/bin/apachectl start , because Apache 's port is 80 , so we netstat -lan | grep 80 to see if port 80 is in the listening state:
Then enter the IP address of the server in IE http://10.10.234.203/
It is successful, indicating that our installation is no problem !
In fact , for the three commands ./configure , make , make install , we can use && to connect the commands to execute, which means that the following commands will only be executed after the current command ends normally. This method is very good, saving time, and also Errors can be prevented. example:
./configure  &&  make  &&  make  install

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940277&siteId=291194637
Recommended