在Linux中安裝軟體

红荼發表於2024-04-05

在Linux中安裝軟體

rpm

軟體安裝查詢

安裝的格式:

rpm -ivh 軟體名

字元 含義
i install安裝
v 顯示過程
h 顯示進度條

查詢已安裝的格式

rpm -q +名稱 查詢是否已安裝

[root@localhost ~]# rpm -q tree
tree-1.6.0-10.el7.x86_64
[root@localhost ~]# rpm -q sdd
未安裝軟體包 sdd 

rpm -qa 查詢所以已安裝的軟體

[root@localhost ~]# rpm -qa
python-cups-1.9.63-6.el7.x86_64
cronie-1.4.11-17.el7.x86_64
libconfig-1.4.9-5.el7.x86_64
clutter-gst3-3.0.22-1.el7.x86_64
gnome-icon-theme-extras-3.12.0-1.el7.noarch
python-configobj-4.7.2-7.el7.noarch
dhclient-4.2.5-58.el7.centos.x86_64
ethtool-4.8-1.el7.x86_64
libpeas-gtk-1.20.0-1.el7.x86_64
wodim-1.1.11-23.el7.x86_64
python-urwid-1.1.1-3.el7.x86_64
hyphen-2.8.6-5.el7.x86_64
fontpackages-filesystem-1.44-8.el7.noarch
python-gobject-3.22.0-1.el7.x86_64
python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
libsss_autofs-1.15.2-50.el7.x86_64
filesystem-3.2-21.el7.x86_64
python-requests-2.6.0-1.el7_1.noarch
m17n-lib-1.6.4-14.el7.x86_64
xkeyboard-config-2.20-1.el7.noarch
tagsoup-1.2.1-8.el7.noarch
.............

rpm -qc 軟體名 查詢軟體的配置檔案

[root@localhost ~]# rpm -qc rpm
/var/lib/rpm/Basenames
/var/lib/rpm/Conflictname
/var/lib/rpm/Dirnames
/var/lib/rpm/Group
/var/lib/rpm/Installtid
/var/lib/rpm/Name
/var/lib/rpm/Obsoletename
/var/lib/rpm/Packages
/var/lib/rpm/Providename
/var/lib/rpm/Requirename
/var/lib/rpm/Sha1header
/var/lib/rpm/Sigmd5
/var/lib/rpm/Triggername
/var/lib/rpm/__db.001
/var/lib/rpm/__db.002
/var/lib/rpm/__db.003
/var/lib/rpm/__db.004
/var/lib/rpm/__db.005
/var/lib/rpm/__db.006
/var/lib/rpm/__db.007
/var/lib/rpm/__db.008
/var/lib/rpm/__db.009

rpm -ql 軟體的所在列表

[root@localhost ~]# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz

rpm -qi 軟體的基本資訊

[root@localhost ~]# rpm -qi tree
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: 2024年04月03日 星期三 13時48分21秒
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, 2014年07月04日 星期五 13時36分46秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : 2014年06月10日 星期二 03時28分53秒
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.

yum

yum是依靠網路實現軟體的安裝;是一個基於RPM包構建的軟體更新機制,能夠自動解決軟體包之間的依賴關係。解決了日常工作中的大量查詢安裝依賴包的時間

通式:

yum install tree -y #安裝tree軟體

[root@localhost ~]# yum install tree -y
已載入外掛:fastestmirror, langpacks
base                                                                             | 3.6 kB  00:00:00     
extras                                                                           | 2.9 kB  00:00:00     
updates                                                                          | 2.9 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                                                | 253 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                                               |  26 MB  00:00:03     
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 tree.x86_64.0.1.6.0-10.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

========================================================================================================
 Package              架構                   版本                            源                    大小
========================================================================================================
正在安裝:
 tree                 x86_64                 1.6.0-10.el7                    base                  46 k

事務概要
========================================================================================================
安裝  1 軟體包

總下載量:46 k
安裝大小:87 k
Downloading packages:
tree-1.6.0-10.el7.x86_64.rpm                                                     |  46 kB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : tree-1.6.0-10.el7.x86_64                                                            1/1 
  驗證中      : tree-1.6.0-10.el7.x86_64                                                            1/1 

已安裝:
  tree.x86_64 0:1.6.0-10.el7                                                                            

完畢!
單機yum倉庫:
[root@localhost /]# mount /dev/sr0 mnt
mount: /dev/sr0 防寫,將以只讀方式掛載
mount: /dev/sr0 已經掛載或 /mnt 忙
       /dev/sr0 已經掛載到 /run/media/root/CentOS 7 x86_64 上
       /dev/sr0 已經掛載到 /mnt 上
[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# ls
bak               CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo
[root@localhost yum.repos.d]# mv *.repo bak
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# yum clean all
已載入外掛:fastestmirror, langpacks
正在清理軟體源: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# yum makecache 
已載入外掛:fastestmirror, langpacks
local                                                                            | 3.6 kB  00:00:00     
(1/4): local/group_gz                                                            | 156 kB  00:00:00     
(2/4): local/filelists_db                                                        | 3.1 MB  00:00:00     
(3/4): local/primary_db                                                          | 3.1 MB  00:00:00     
(4/4): local/other_db                                                            | 1.2 MB  00:00:00     
Determining fastest mirrors
後設資料快取已建立
[root@localhost yum.repos.d]# yum install tree -y
已載入外掛:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 tree.x86_64.0.1.6.0-10.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

========================================================================================================
 Package              架構                   版本                           源                     大小
========================================================================================================
正在安裝:
 tree                 x86_64                 1.6.0-10.el7                   local                  46 k

事務概要
========================================================================================================
安裝  1 軟體包

總下載量:46 k
安裝大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : tree-1.6.0-10.el7.x86_64                                                            1/1 
  驗證中      : tree-1.6.0-10.el7.x86_64                                                            1/1 

已安裝:
  tree.x86_64 0:1.6.0-10.el7                                                                            

完畢!

編譯安裝

nginx 執行一個 網站你安裝了 nginx 軟體 等於搭建了一個 網站
[root@localhost ~]# mkdir /data
[root@localhost ~]# cd /data
[root@localhost data]# wget http://nginx.org/download/nginx-1.18.0.tar.gz #下載原始碼包
[root@localhost data]#tar xf nginx-1.18.0.tar.g2
[root@localhost nginx-1.18.0]#cd nginx-1.18.0/
[root@localhost nginx-1.18.0]#yum -y install make gcc pcre-devel openssl-devel zlib-devel openssl openssl-devel                  #安裝依賴環境
[root@localhost nginx-1.18.0]#./configure --prefix=/apps/nginx  		#檢測環境, 指定安裝目錄
[root@localhost nginx-1.18.0]#make -j2			#編譯    -j2   2個核心編譯
[root@localhost nginx-1.18.0]#make instal			#將軟體複製到 前面規定的路徑
[root@localhost ~]#In -s /apps/nginx/sbin/nginx	 /usr/local/sbin 	#建立軟連結
[root@localhost ~]#nginx   #可以補全
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#setenforce 0
[root@localhost ~]#cur  ip地址(本機的)
[root@localhost ~]# curl 172.16.208.10
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
瀏覽器中 輸入 ip地址

相關文章