One . About software packages
stay linux Installation package is required for software installation in , There are various types of software packages ：.zip,.rar,.rpm,.tar.gz,.tar. Software package can also be divided into source code package and binary
package , A source code package is a package that has not been compiled , Need to go through GCC、C++ Compiler environment compiles to run . Binary packages do not need to be compiled , It can be installed and used directly . Distinguish whether it is
The source code package or binary package has to be judged based on the files in the software package , contain .h、.c、.cpp、.cc Wait for the end of the source file , Call it a source code package , And the software package contains
stay bin Catalog （bin There are executable files in the directory ）, Call it binary package . Source packages are highly customizable , You can freely choose the function you need .
Two . Software compilation process
1. Compile the source code to be available for Linux It takes two steps to run the binaries ：
- Use gcc The compiler compiles the source code into a target file
- Again using gcc The compiler links the object file into a binary file
The process seems simple , But it is not . The source code of a software is often encapsulated in multiple source files , In addition, these documents have intricate dependencies , Compiling requires strict compliance with the instructions
In a certain order , This undoubtedly increases the difficulty of compiling . Fortunately make Commands can help us simplify the compilation process . The whole compilation process is condensed into Makefile In file ( tell
make Command how to compile and link programs ), When executed make On command ,make Will look in the current directory for Makefile file , And complete the whole according to the requirements of the document
The build process . and Makefile File by configure Command generation . When executed configure On command ,configure According to the current system environment, it will dynamically generate a suitable
Makefile file , for make Command to use .
2.Linux Source code installation steps
- Get the source code and unzip it
- see INSTALL And README file ： Unzip and check INSTALL And README file , These two files describe the installation method and precautions of the software in detail
- establish Makefile file ： perform configure command , Generate Makefile file
- compile ： perform make clean;make Command to compile the source code into a binary file .PS:make clean The command is used to clear the target file generated by the last compilation , This step is optional , But to ensure the success of the compilation , It's better to add , Prevent compilation failure due to residual object files in the software
- install ： perform make install Command to install the binary file compiled in the previous step to the specified directory
3、 ... and . Compile and install common parameters
# ./configure a. Specify installation path , for example --prefix=/usr/local/nginx b. Enable or disable a function , for example --enable-ssl, --disable-filter --with-http_ssl_module c. Associated with other software , for example --with-pcre d. Check the installation environment ( Check the dependent external environment ), For example, whether there is a compiler gcc, Whether to meet the software dependency requirements The resulting ：Makefile # make -j 4 # Press Makefile File compilation , have access to -j 4 Appoint 4 The core CPU compile , Speed up # make install # Press Makefile Define the file path to install # make clean # Clear the last time make The command produces object and Makefile file . Use scenarios ： When it needs to be re executed configure when , You need to perform make clean #make uninstall # Remove the installation package , Sometimes the deletion is not clean , So we suggest that when you install , stay configure Step add a ： --prefix Parameters . When deleting or backing up in this way , Directly to delete --prefix The specified installation directory operation is OK .
Four . Source code compilation error solution
1. First, compiling software requires a variety of compilers , All kinds of dependency packages , Installing dependency packages before compiling reduces errors . Pay attention to see INSTALL And README file , These two articles
The software installation method and precautions are introduced in detail ;
2. according to ./configure To solve the problem , Install dependent packages if they are missing . If you know that the dependent software name is missing , But I don't know the dependency package , have access to yum
search The software name , See which dependency package belongs to , Then install ;
3. have access to http://www.rpmseek.com/index.html Find the software you need .
5、 ... and . Features of various software installation methods
- Use yum perhaps rpm Install the software directly ： It is easy to operate , The software version is low （ Stable version ）, Good stability , Easy to manage , Poor performance ;
- Source code compilation and installation software ： Operation trouble , The software version is new , Can be customized , Slightly less stable , The management is a little poor , Good performance .