Software installation is a necessary function of the system. Naturally, Linux also has it. Linux installation has two ways: rmp and source code.
- rpm: This is a bit like an exe file in windows. You can click Install. The file format is rmp, which is the format encapsulated by the source code, similar to exe file.
- Source code: software source code, easy to modify and optimize.
RPM installation can be divided into two parts. One is the RPM command itself to install rpm. Another one is installed through yum, which is a package manager at the front end of the shell, almost managed by RPM packages.
Although this installation method is mentioned, it is not recommended, because it will prompt you that you lack an associated software, but the prompt is not obvious. Unless you are an old hand, it will be very urgent to use.
This is just a part of the parameter command. After all, many users are more accustomed to using yum.
Now let's look at some parameters and their meaning.
|-v||Displays the installation process|
|-h||hash is generally used with rmp -ivh|
|-e||Uninstall the software package of rpm. If other software depends on this software, an error will occur. Of course, you can force the uninstall: rpm -e --nodeps python. However, forced uninstallation is generally not recommended. If so, other software will not be available.|
|-Q < installation package name >||Find, for example, rpm -q python|
|-QF < file or folder >||Which package does a file belong to when viewing it|
|-Qi < software name >||View the information of the software package [factory information]|
|-qa||Find all installed software packages matching the XXX keyword. rpm -qa will display all commonly used rpm -qa | grep python through the pipeline character|
|-ql||Check which files the package contains rpm -ql python|
You can understand the above command. It is not recommended to use the above command to install rpm installation software. Why?
- Unofficial rpm packages are packaged by others based on the source code. Although it is convenient to install, it is impossible to judge whether they have been modified by the provider, so the security cannot be guaranteed.
- Packages in rpm format are generally old unless officially provided.
- rpm is also the most fatal reason, that is, the dependency of packages. For example, installing b requires a to be safe, but sometimes the prompts are not detailed and need a deep understanding.
Therefore, it is enough to understand rpm. For example, only rpm is provided during work, and the user knows how to install it.
Yum is a package manager for Shell front-end software. It is based on rpm package management. It can automatically download and install rpm packages from the specified server, and install all dependent packages at one time. Yum is a Shell front-end package manager in Fedora, RedHat and SUSE. I use centos7 as the community version of RedHat, so I can use yum. Other versions are still managed by their own package managers. For example, apt (Advanced Packaging Tool) is a Shell front-end package manager in Debian and Ubuntu. (lazy once, the following figure directly intercepts other people's)
yum can be understood as the official rpm package collation of redhat, and will also check whether other dependent packages need to be installed.
Or list commonly used commands.
#List all software that can be updated yum check-update # Update software yum update If you update a software yum update Software name # Install software yum install Software name # Lists the list of software that can be installed yum list However, it is generally not used alone, but yum list | grep Software or yun list Name (or name)*) # Remove installed software yum remove Software name #Find package command yum search Name (this is a bit like a regular expression, which will be searched if it contains) # Install local rpm package yum localinstall Package name -y Install local packages # yum group install update command yum groupinstall Group name e.g yum install mysql Only install mysql ，however yum groupinstall msyql In addition to installation mysql Also installed mysql Some other tools. yum groupupdate Group name yum grouplist Group name yum groupremove Group name # Clear cache yum clean packages: Clear the package in the cache directory yum clean headers: Clear the cache directory headers yum clean oldheaders: Clear old in cache directory headers yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :Clear the software package and old in the cache directory headers
# Install python yum install python
It's as follows: I'm too lazy to uninstall. Because it's installed, this appears, as shown in the following figure. What should be more concerned is that python is version 2.7 and the prompt is the latest. It can be seen that although yum is more convenient than rpm, it has one
Many times, if you install the latest software, you need to download the compressed package from the software official website and then process it.
Supplement: basic format of rpm
python-2.7.5-90.el7.x86_64 name: python Version No.: 2.7.5-90 Applicable operating system: el7.x86_64
Supplement and modify yum source
Because the default server of yum is foreign, and sometimes the download in China is very slow, there are many resources in China, such as Netease, Tsinghua and Alibaba.
In order to facilitate downloading, sometimes we need to modify it into domestic resources
The configuration file is: etc/yum.repos.d/CentOS-Base.repo
# Back it up first mv etc/yum.repos.d/CentOS-Base.repo etc/yum.repos.d/CentOS-Base.repo.bak #Download the corresponding CentOS-Base.repo file in China. Because I use centos7, I download 7 Ali source: http://mirrors.aliyun.com/repo/Centos-7.repo Netease source: http://mirrors.163.com/.help/CentOS7-Base-163.repo # This requires the wget command. If you can't directly enter the web address into the browser, you can download it directly wget http://mirrors.aliyun.com/repo/Centos-7.repo # After downloading, put it into the etc/yum.repos.d file, and remember to change the name mv Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo
wget is a free tool for automatically downloading files from the network. There are two most commonly used tools:
# Download the httts://www.test.com/test.tar.gz file wget httts: //www.test.com/test.tar.gz it is downloaded to the current file directory by default #Download the httts://www.test.com/test.tar.gz file, which is named t.tar.gz locally wget -o t.tar.gz httts: //www.test.com/test.tar.gz
Source code installation is to compile the source code and then install it. This installation can be applied to all linux.
First demonstrate some by installing nginx. Let's do a demonstration.
Check whether the dependent software is installed #gcc compiler is required. This is a software compiled from the source code. If it is ignored, please download it yum -y install gcc #pcre is also required. Sometimes it comes with its own pcre library, but it is prompted that it is not installed because of the lack of pcre devel (pcre development tool) yum Install -y pcre pcre-devel #zlib, openssl and pcre are the same yum install -y zlib zlib-devel yum install -y openssl openssl-devel
The previous step is to install the source code. After installing the dependent package installed by nginx, start the source code installation
# The first step is to download the nginx source code compression package wget https://nginx.org/download/nginx-1.12.0.tar.gz #Step 2: unzip tar -zxvf nginx-1.12.0.tar.gz # Enter the unzipped file and take a look at the specific ls
The official website will give you a help document to tell you how to install it. If you want to know more, you can see some README
Three commands are required for source code installation:
|configure||Specify the software function and installation path, and check whether there are problems in the environment, such as the lack of pcre library|
|make||Compile the source code. In fact, if you have learned c, you will understand that it is to compile c files into binary o files|
|make install||Install the software to the path specified above.|
#Specify the installation address. Generally, nginx files are installed in / usr/local/nginx ./configure --prefix=/usr/local/nginx Specify the address of the installation # Start compilation make If there are exceptions, they can be ignored as long as they are not erro， #Install the software in the previously specified location make install
The source code is installed through the source code. Sometimes, when installing software, some software is similar to the green software of windows, and can be installed directly by modifying the configuration file. Some officials have simply sorted out the software and can be installed by running its sh format file.
Next, install jdk, myql and ide separately for demonstration.