Software installation methods and strategies in CentOS 7

Source: Internet
Author: User
Tags perl script

Software installation methods and strategies in CentOS 7

Original article link

In 2010, we officially started to get started with Linux. The entry release version is Ubuntu 10.10, and later transitioned to Ubunu 11.04, which also tried many other mainstream releases. After entering the lab, we started to use CentOS 5, then CentOS 6, and now evolved to CentOS 7.

Linux, which has been used for four years, has been suffering from the first three years of hard work. It has wasted a lot of time and gained a lot of experience and lessons. Now it may be really old, and I don't want to worry about it anymore. I just want to keep using it after a system is configured.

Why write/read this article?

If you use Linux, especially CentOS, you may encounter some pitfalls or things that can't be tolerated by others:

  1. The software package version in official sources is too old to meet functional requirements;
  2. Software packages from multiple sources have version conflicts;
  3. Manually compile the software. By default, different files are stored in/usr/localDifferent sub-directories make updating and deleting software troublesome.
  4. Wait...

After several CentOS reinstalls, the following software installation methods and principles are summarized to ensure the stability and cleanliness of the current system, minimize the re-installation impulse caused by system cleanliness.

The following statement is only applicable to CentOS7 and may be of reference to other releases.

Official Origin

CentOS comes with four official sources. By default, base, updates, and extras are opened. These three sources contain about 9000 software packages, which are the most stable and trustworthy source.

Therefore, if a software package is in the official source, it should be installed through the official source:

sudo yum install PackageName
Third-party source

Although official sources contain many software packages, they cannot meet daily requirements. Fortunately, there is a third-party source, which can be used as a supplement to the Official source.

When using third-party sources, you are most afraid of encountering these two problems:

  1. Third-party sources and official sources have the same package, resulting in replacement by third-party sources;
  2. The same software package exists in multiple third-party sources, and the versions are inconsistent and conflict exists;

These two problems are often fatal and have unexpected consequences. Therefore, the third-party source should follow the following principles:

  1. Select a reliable third-party source. Make sure that the third-party source does not replace the package in the third-party source;
  2. Use as few third-party sources as possible to prevent conflicts between third-party sources;

For CentOS, the following third-party sources are used based on the above principles:

  1. Large third-party source, confirmed not to replace the official source package, and there is no conflict between them
    1. EPEL: contains more than 6500 software and is essential for scientific research.
    2. ELRepo: contains dozens of hardware drivers
    3. Nux Dextop: multimedia-related software packages (conflicts with some EPEL software and can be ignored)
  2. Some small third-party sources only contain a few software, confirm that they do not conflict with the official source and EPEL source, you can also add
    1. Google Chrome: Google Chrome is included and will not conflict with official sources or EPEL sources;
    2. Adobe: only the flash plug-in is included. It is confirmed that no conflict exists;
    3. Dropbox: Only one dropbox software is included, and it has been confirmed that there will be no conflict;

Therefore, if a software package is located in EPEL, ELRepo, or a small third-party source, add the third-party source andyumCommand installation:

sudo yum install PackageName
Official rpm package

Most non-open-source software is not available in CentOS official sources or EPEL. Some software official websites provide official rpm packages. In this case, you can download the rpm package corresponding to the current system from the official website and install it directly using the following command:

sudo rpm -i PackageName.rpm

For example, WPS for Linux is one of them. During the installation process, the rpm command will automatically check the dependency. If the packages that the software depends on can be found in the official source and EPEL source, it will be automatically installed.

Directly installing the rpm package is quite easy, but the software cannot be updated by yum, which is a little troublesome. Some software, such as Google, Dropbox, and Adobe mentioned above, can also be installed in this way, and the system will be added to the source at the same time of installation, such software can be easily updated and deleted.

Unzip

Some software officially provides compressed packages. After decompression, you can directly run the binary files, such as many software written in Java. This type of software does not provide source code, but provides binary files that can be directly executed on the current platform. Most non-open-source commercial software adopts this approach.

  1. For example, sublime_text, pycharm, mendeley, TauP, and sac can be decompressed directly, and then the decompressed folder is copied/optDirectory, and then add the bin directory of the software to the PATH.
  2. For example, Mathematics, Matlab, and intel studio. The installation script is provided in the software package and can be installed by executing the script;

In Linux, commercial software or third-party software is installed/optDirectory, which is also the default installation path for most commercial software packages. Follow this habit as much as possible.

Third-party rpm package

Some software, CentOS and EPEL sources cannot be found, and the rpm package is not officially provided, but other third-party sources provide the rpm package. Situation analysis:

  • If the third-party source contains only a small number of packages and is sure that these packages do not conflict with the official source and other used third-party sources, you can add the third-party source.
  • If the third source contains a lot of software, it is likely to conflict with the official source or EPEL source.
    • If the package does not have complex dependencies, install the rpm package in the source directly;
    • If the software package depends on other packages in the third source, discard and look for other methods;
Third-party Package Manager

Different releases use different software package managers. CentOS uses yum and Ubuntu uses apt-get. In recent years, there have been some third-party package managers unrelated to the release, such as Linuxbrew, Gentoo Prefix, and pkgsrc.

Linuxbrew

Linuxbrew is transplanted to Linux from Homebrew, a popular OS X platform. Linuxbrew can be used as a supplement to the package manager provided by the system. It features:

  • All software is installed on${HOME}/.linuxbrewDirectory;
  • The software version is relatively new;
  • Install, uninstall, info, list, update, upgrade, and other functions
  • If the library does not have the required software package, you can easily create a formulae

After trying it out, linuxbrew will solve the dependency problem internally. For example, I tried to install terminator through linuxbrew and found that terminator depends on Python. Although the system has already installed python, linuxbrew will still install a copy of python, because python depends on more things, more software packages are installed in the home. Moreover, linuxbrew compiles software from the source code, so it is relatively slow.

Compile source code

Most software should be installed in the previous methods. If the software is not installed, ask yourself, do you really need to install the software. Do not install it unless necessary. If the software is required, it must be compiled manually.

Common source code compilation is generally the following steps. Of course, specific treatment:

tar -xvf xxxx.tgz./configure --prefix=/opt/xxxxmakesudo make install

Generally, the default installation directories of such software are/usr/local, The final files will be placed separately/usr/localIn the bin, lib, share, and man directories.

I personally do not like this method very much, because as a software compiled by source code, it means that the compiler must fully assume the obligation to manage the software, this placement method may cause a lot of trouble to update or uninstall the software. Therefore, I always add prefix to configure to manually specify the installation path. To uninstall the software, you can directly Delete the corresponding directory under/opt. to update the directory, you can also delete it and recompile it again. The trouble is that you need to manually add the bin directory of the software to the PATH, and you may need to modify it.LD_LIBRARY_PATH. However, in general, there are few software that requires source code compilation, so it will not cause too much trouble.

Compile code

Well, I don't know how to start the title ..

The previous section "compile source code" mainly targets some large software packages. This section "compile code" refers to the handling of some very professional small code packages. For example, some software packages need only a binary file after compilation, so there is no need to install/optThe proper method is to create the bin directory under your HOME and add the directory.bashrcAnd copy the compiled binary file to this directory:

mkdir ${HOME}/binecho 'export PATH=${HOME}/bin:$PATH'>> ~/.bashrc

For example, my${HOME}/binThe directory contains the following files:

  • distaz: Returns the longitude and latitude of two points on the earth, and calculates the earthquake distance and azimuth.
  • pssac: Draw the SAC file in GMT
  • rdseed: SEED format to SAC format
  • win2sac_32,catwin32: Programs provided by the Hi-net website for processing Hi-net data
  • st: Sublime_text is installed/optCreate a soft link to call sublime text in the command line.
  • wlt.pl: In-school scripts used to log on to the network, modify the network port on the command line, so happy
  • fk,fk.pl,syn,trav: Prof. Lupei Zhu is a program used to calculate and synthesize seismic maps. There are many source codes. The three executable files and a perl script are actually needed.
  • matlab: Pointing to a soft connection of matlab;

Do not place any binary files in the bin. here you should only put some common commands or common tools.

Self-contained Software

There is a type of software, which has many modules or packages. To manage these modules, you need to have your own module/Package Manager. This is represented by TeX, Perl, and Python. For this type of software, its many modules are the biggest advantage and the most worthwhile resource. Therefore, I usually choose to install them manually for the following reasons:

  • The system source cannot contain all modules of the software;
  • Updates to the software module in the system source are far behind the latest version;

Of course, you can still use the Package Manager that comes with the software to install the module even if you use the version that comes with the system. But it will cause:

  • Some modules use the system yum management, and some modules use the Package Manager that comes with the software for management;
  • The modules installed in yum are generally older, and most of the software package manager must be installed in the latest version;

This will lead to confusion in module management. In addition, when you use the software package to manage its installation modules, it may depend on the latest version of other modules, if this module is an older version installed through the system yum, the installation of this module may fail.

Therefore, this type of software is generally installed separately and managed using the package manager module:

  • TeXLive: Installs the image using the TeXLive iso image file and uses its own tlmgr management package.
  • Perl: Install the latest Perl version through plenv and use the cpanm installation module that comes with plenv.
  • Python: Install the latest Python version through pyenv, and use the pip installation module that comes with Python.
Exceptions

There are always exceptions with rules.

Third-party source

Mosquito-myrepo is a private maintenance source, which includes the Chinese Input Method, QQ, Feixin, Zhizhi note, youdao dictionary, Baidu cloud, and several audio and video players. I love and hate this source. It provides software that many Chinese people need, but because it relies on third-party software sources other than EPEL, this may cause package conflicts. Therefore, exercise caution when using the source.

Summary

Summary:

  1. Add EPEL source, Nux Dextop, ELRepo source, and other small third-party sources to the System
  2. Install from the source
  3. You cannot find the rpm package for installation from the source.
  4. If you cannot find the rpm package, try linuxbrew.
  5. Do not compile manually if it does not support manual compilation.
Revision history
  1. : First draft;
  2. : ELRepo sources are added to third-party sources;
  3. : Nux Dextop is added to a third-party source;

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.