DPKG包:是由 Debian Linux 所開發出來的包管理機制,經過 DPKG 包,Debian Linux 就能夠進行軟件包管理。主要應用在 Debian 和 unbuntu 中。php
RPM 包:是由 Red Hat 公司所開發的包管理系統。功能強大,安裝、升級、查詢和卸載 都很是簡單和方便。目前不少 Linux 都在使用這種包管理方式,包括 Fedora、CentOS、 SuSE 等,這裏是以CentOS 7.x爲例,主要學習RPM包html
[root@m01 tools]# rpm -ivh mysql-community-server-8.0.20-1.el8.x86_64.rpm error: Failed dependencies: # 依賴檢測失敗 libc.so.6(GLIBC_2.28)(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libcrypto.so.1.1()(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libcrypto.so.1.1(OPENSSL_1_1_1)(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64 libssl.so.1.1()(64bit) is needed by mysql-community-server-8.0.20-1.el8.x86_64
這就是函數庫依賴,安裝mysql須要先安裝libc.so.六、libcrypto.so.1.1等等,去哪裏找?http://www.rpmfind.net/linux/rpm2html/search.php
和
https://pkgs.org/
兩個地址搜索node
命名規則mysql
htop - 1.0.3 - 1 . el7 . rf.x86_64. rpm
linux
htop
: 軟件包明1.0.3
軟件版本1
軟件發行次數e17
軟件發行商。el7是 RedHat 公司發佈,適合 RHEL7.x(Red Hat Enterprise Linux)和 CentOS7.x 下使用rf.x86_64
x86_64(64 位 CPU 能夠安裝)和 noarch(沒有硬 件限制)等文件名包全名:若是操做的是未安裝軟件包,則使用包全名,並且須要注意絕對路徑nginx
包名:若是操做的是已經安裝的軟件包,則使用包名便可,系統會生產 RPM 包的數據庫(/var/lib/rpm/),並且能夠在任意路徑下操做git
默認安裝位置github
/etc/ | 配置文件安裝目錄 |
---|---|
/usr/bin/ | 可執行的命令安裝目錄 |
/usr/lib/ | 程序所使用的函數庫保存位置 |
/usr/share/doc/ | 基本的軟件使用手冊保存位置 |
/usr/share/man/ | 幫助文件保存位置 |
安裝命令web
語法格式:rpm –ivh 包全名
算法
-i
install 安裝(install)
-v
顯示更詳細的信息(verbose)
-h
打印#顯示安裝進度(hash)
--nodeps
不檢測依賴性安裝。軟件時會檢測依賴性,肯定所需的底層軟件是否安裝。 若是沒有安裝則會報錯。若是我無論依賴性,想強行安裝,可使用這個選項。注意: 這樣不檢測依賴性安裝的軟件基本是不能使用的,因此不建議這樣作
--replacefiles
替換文件安裝。若是安裝軟件包,但是包中部分文件已經存在,那麼 正常安裝時候,會報錯「某個文件已經存在」從而致使軟件沒法安裝,使用這個選項可 以忽視這個報錯,而覆蓋安裝
--replacepkgs
替換軟件包安裝。若是軟件包已經安裝,此選項能夠把軟件包重複安 裝一遍。
--force
強制安裝。不論是否已經安裝,都從新安裝。就是—replacefiles 和 —replacepkgs 的綜合。
--test
測試安裝。不會實際安裝,只是檢測一下依賴性。
--prefix
指定安裝路徑。爲安裝軟件指定安裝路徑,而不使用默認安裝路徑。注意: 若是指定了安裝路徑,軟件沒有安裝到系統默認路徑中的話,系統會找不到這些安裝的 軟件,須要進行手工配置才能被系統識別。因此 rpm 包通常都採用默認路徑安裝
CentOS 6.x
[root@localhost ~]# service 服務名 start|stop|restart|status 參數: start: 啓動服務 stop: 中止服務 restart: 重啓服務 status: 查看服務狀態
CentOS 7.x
[root@localhost ~]# systemctl start|stop|restart|status 服務名 參數: start: 啓動服務 stop: 中止服務 restart: 重啓服務 status: 查看服務狀態
[root@localhost ~]# rpm –Uvh 包全名 選項: -U(大寫) 升級安裝,若是沒有安裝過,系統直接安裝。若是安裝過的版本較舊,則 升級到新版本(upgrade) [root@localhost ~]# rpm –Fvh 包全名 選項: -F(大寫) 升級安裝,若是沒有安裝過,則不會安裝。必須安裝有較舊版本,才能升級(freshen)
[root@localhost ~]# rpm -e 包名 選項: --nodeps 不檢查依賴性
[root@localhost ~]# rpm –q 包名 選項: -q 查詢(query) -a:全部(all) -i: 查詢軟件信息(information) -p: 查詢沒有安裝的軟件包(package) -l: 列出軟件包中全部的文件列表和軟件所安裝的目錄(list) -f: 查詢系統文件屬於哪一個軟件包(file) -R: 查詢軟件包的依賴性(requires)
yum在線安裝RPM包的最大好處就是會自動給你解決依賴關係,一鍵安裝。
yum提供了查找、安裝、刪除某一個、一組甚至所有軟件包的命令。yum 源配置文件保存在/etc/yum.repos.d/
目錄中,文件的擴展名必定是*.repo
,這個目錄中有 5 個 yum 源配置文件,默認狀況下 CentOS-Base.repo 文件生效
[root@localhost ~]# ls CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo CentOS-Debuginfo.repo CentOS-Media.repo # 默認源配置 [root@localhost yum.repos.d]# vim /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch& repo=os baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # [base]:容器名稱,必定要放在[]中。 # name:容器說明,能夠本身隨便寫。 # mirrorlist:鏡像站點,這個能夠註釋掉。 # baseurl:咱們的 yum 源服務器的地址。默認是 CentOS 官方的 yum 源服務器,是可使用的。 若是你以爲慢,則能夠改爲你喜歡的 yum 源地址。 # enabled:此容器是否生效,若是不寫或寫成 # enabled=1 則表示此容器生效,寫成 enabled=0 則表示此容器不生效。 # gpgcheck:若是爲 1 則表示 RPM 的數字證書生效;若是爲 0 則表示 RPM 的數字證書不生效。 # gpgkey:數字證書的公鑰文件保存位置。不用修改。
yum [options] [command] [package ...]
說明:
options:
選項包括-h(幫助),-y(當安裝過程提示選擇所有爲」yes」),-q(不顯示安裝的過程)等等[command]
: 所要進行的操做, install(安裝) 、 update(更新)、remove(刪除)等[package …]
是操做的對象(安裝包1)yum具體參數和選項: 使用yum --help
[root@backup ~]# yum --help Loaded plugins: fastestmirror, langpacks Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data deplist List a package's dependencies distribution-synchronization Synchronize installed packages to the latest available versions downgrade downgrade a package erase Remove a package or packages from your system fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts. fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots. groups Display, or use, the groups information help Display a helpful usage message history Display, or use, the transaction history info Display details about a package or group of packages install Install a package or packages on your system langavailable Check available languages langinfo List languages information langinstall Install appropriate language packs for a language langlist List installed languages langremove Remove installed language packs for a language list List a package or groups of packages load-transaction load a saved transaction from filename makecache Generate the metadata cache provides Find what package provides the given value reinstall reinstall a package repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them repolist Display the configured software repositories search Search package details for the given string shell Run an interactive yum shell swap Simple way to swap packages, instead of using shell update Update a package or packages on your system update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system updateinfo Acts on repository update information upgrade Update packages taking obsoletes into account version Display a version for the machine and/or available repos. Options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C, --cacheonly run entirely from system cache, don't update cache -c [config file], --config=[config file] config file location -R [minutes], --randomwait=[minutes] maximum command wait time -d [debug level], --debuglevel=[debug level] debugging output level --showduplicates show duplicates, in repos, in list/search commands -e [error level], --errorlevel=[error level] error output level --rpmverbosity=[debug level name] debugging output level for rpm -q, --quiet quiet operation -v, --verbose verbose operation -y, --assumeyes answer yes for all questions --assumeno answer no for all questions --version show Yum version and exit --installroot=[path] set install root --enablerepo=[repo] enable one or more repositories (wildcards allowed) --disablerepo=[repo] disable one or more repositories (wildcards allowed) -x [package], --exclude=[package] exclude package(s) by name or glob --disableexcludes=[repo] disable exclude from main, for a repo or for everything --disableincludes=[repo] disable includepkgs for a repo or for everything --obsoletes enable obsoletes processing during updates --noplugins disable Yum plugins --nogpgcheck disable gpg signature checking --disableplugin=[plugin] disable plugins by name --enableplugin=[plugin] enable plugins by name --skip-broken skip packages with depsolving problems --color=COLOR control whether color is used --releasever=RELEASEVER set value of $releasever in yum config and repo files --downloadonly don't update, just download --downloaddir=DLDIR specifies an alternate directory to store packages --setopt=SETOPTS set arbitrary config and repo options --bugfix Include bugfix relevant packages, in updates --security Include security relevant packages, in updates --advisory=ADVS, --advisories=ADVS Include packages needed to fix the given advisory, in updates --bzs=BZS Include packages needed to fix the given BZ, in updates --cves=CVES Include packages needed to fix the given CVE, in updates --sec-severity=SEVS, --secseverity=SEVS Include security relevant packages matching the severity, in updates Plugin Options:
yum install yum-fastestmirror
yum install yumex
yum grouplist
yum install
所有安裝yum install package1
安裝指定的安裝包package1yum groupinsall group1
安裝程序組group1yum update
所有更新yum update package1
更新指定程序包package1yum check-update
檢查可更新的程序yum upgrade package1
升級指定程序包package1yum groupupdate group1
升級程序組group1yum info package1
顯示安裝包信息package1yum list
顯示全部已經安裝和能夠安裝的程序包yum list package1
顯示指定程序包安裝狀況package1yum groupinfo group1
顯示程序組group1信息yum search string
根據關鍵字string查找安裝包yum search~
查找軟件包yum list
列出全部可安裝的軟件包yum list updates
列出全部可更新的軟件包yum list installed
列出全部已安裝的軟件包yum info
列出全部軟件包的信息yum info updates
列出全部可更新的軟件包信息yum info installed
列出全部已安裝的軟件包信息yum info extras
列出全部已安裝但不在Yum Repository 內的軟件包信息yum provides~
列出軟件包提供哪些文件yum remove package1
刪除程序包package1yum groupremove group1
刪除程序組group1yum deplist package1
查看程序package1依賴狀況yum 會把下載的軟件包和header存儲在cache中,而不會自動刪除。若是咱們以爲它們佔用了磁盤空間,可使用yum clean指令進行清除.
yum clean packages
清除緩存目錄下的軟件包yum clean headers
清除緩存目錄下的 headersyum clean oldheaders
清除緩存目錄下舊的 headersyum clean, yum clean all (= yum clean packages; yum clean oldheaders)
清除緩存目錄下的軟件包及舊的headers源碼安裝的優勢,編譯安裝過程,能夠設定參數,按照需求,進行安裝,而且安裝的版本,能夠本身選擇,靈活性比較大。
源碼安裝的缺點,因爲安裝包過新或者是其餘問題,致使依賴的包沒有,或者版本太低。這個時候就要解決包的依賴問題,linux系統中有的包,一個依賴一個,可能裝一個小東西,就要解決一堆包的依賴問題,花不少時間解決包的依賴問題,得不嘗失。源碼安裝的多了,不敢升級系統,升級系統,可能會致使之前手動裝的東西,不能用
./configure
編譯前準備工做, 指定安裝目錄/功能模塊等選項,使用./configure --help查看選項make
編譯 生成可執行的二進制程序文件make clean
若是在./configure
或make
編譯中報錯,那麼咱們在從新執行命令前必定要記得執行 make clean
命令,它會清空 Makefile 文件或編譯產生的.o
頭文件。make install
編譯安裝, 將編譯好的文件複製到安裝目錄[root@web02 tools]# wget https://nginx.org/download/nginx-1.18.0.tar.gz
[root@web02 tools]# tar -zxvf nginx-1.18.0.tar.gz [root@web02 tools]# ls nginx-1.18.0 nginx-1.18.0.tar.gz
useradd -M www -s /sbin/nologin
[root@web02 tools]# useradd -M www -s /sbin/nologin [root@web02 tools]# id www uid=1005(www) gid=1005(www) groups=1005(www)
./configure
指定安裝目錄、功能模塊等./configure --prefix=/Applications/nginx-1.18.0 --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
參數名稱 | 備註 |
---|---|
--prefix=value |
指向安裝目錄 |
--sbin-path |
指向(執行)程序文件(nginx ) |
--conf-path= |
指向配置文件(nginx.conf ) |
--error-log-path= |
指向錯誤日誌目錄 |
--pid-path= |
指向 pid 文件(nginx.pid ) |
--lock-path= |
指向 lock 文件(nginx.lock )(安裝文件鎖定,防止安裝文件被別人利用,或本身誤操做。)進程ID文件 |
--user= |
指定程序運行時的用戶名 |
--group= |
指定程序運行時的用戶組名 |
--builddir= |
指向編譯目錄 |
--with-rtsig_module |
啓用 rtsig 模塊支持(實時信號) |
--with-select_module |
啓用 select 模塊支持(一種輪詢模式,不推薦在高載環境下使用)禁用:--without-select_module |
--with-poll_module |
啓用 poll 模塊支持(功能與 select 相同,與 select 特性相同,爲一種輪詢模式,不推薦在高載環境下使用) |
--with-file-aio |
啓用 file aio 支持(一種 APL 文件傳輸格式) |
--with-ipv6 |
啓用 ipv6 支持 |
--add-module= |
啓用外部模塊支持 |
--with-cc= |
指向 C 編譯器路徑 |
--with-cpp= |
指向 C 預處理路徑 |
--with-cc-opt= |
設置 C 編譯器參數 |
--with-ld-opt= |
設置鏈接文件參數 |
--with-cpu-opt= |
指定編譯的 CPU,可用的值爲:pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64 |
--without-pcre |
禁用 PCRE 庫 |
--with-pcre |
啓用 PCRE 庫 |
--with-pcre= |
指向 PCRE 庫文件目錄 |
--with-pcre-opt= |
在編譯時爲 PCRE 庫設置附加參數 |
--with-md5= |
指向 MD5 庫文件目錄(消息摘要算法第五版,用以提供消息的完整性保護) |
--with-md5-opt= |
在編譯時爲 MD5 庫設置附加參數 |
--with-md5-asm |
使用 MD5 彙編源 |
--with-sha1= |
指向 sha1 庫目錄(數字簽名算法,主要用於數字簽名) |
--with-sha1-opt= |
在編譯時爲 sha1 庫設置附加參數 |
--with-sha1-asm |
使用 sha1 彙編源 |
--with-perl= |
設定 perl 庫文件路徑 |
--with-zlib= |
指向 zlib 庫目錄 |
--with-zlib-opt= |
在編譯時爲 zlib 設置附加參數 |
--with-zlib-asm= |
爲指定的 CPU 使用 zlib 彙編源進行優化,CPU 類型爲 pentium, pentiumpro |
--with-libatomic |
爲原子內存的更新操做的實現提供一個架構 |
--with-libatomic= |
指向 libatomic_ops 安裝目錄 |
--with-openssl= |
指向 openssl 安裝目錄 |
--with-openssl-opt |
在編譯時爲 openssl 設置附加參數 |
--with-debug |
啓用 debug 日誌 |
--with-http_ssl_module |
啓用 ngx_http_ssl_module 支持(使支持 HTTPS 請求,需已安裝 openssl) |
--with-http_realip_module |
啓用 ngx_http_realip_module 支持(這個模塊容許從請求標頭更改客戶端的 IP 地址值,默認爲關) |
--with-http_addition_module |
啓用 ngx_http_addition_module 支持(做爲一個輸出過濾器,支持不徹底緩衝,分部分響應請求) |
--with-http_xslt_module |
啓用 ngx_http_xslt_module 支持(過濾轉換 XML 請求) |
--with-http_image_filter_module |
啓用 ngx_http_image_filter_module 支持(傳輸 JPEG/GIF/PNG 圖片的一個過濾器)(默認爲不啓用。GD 庫要用到) |
--with-http_geoip_module |
啓用 ngx_http_geoip_module 支持(該模塊建立基於與 MaxMind GeoIP 二進制文件相配的客戶端 IP 地址的 ngx_http_geoip_module 變量) |
--with-http_sub_module |
啓用 ngx_http_sub_module 支持(容許用一些其餘文本替換 Nginx 響應中的一些文本) |
--with-http_dav_module |
啓用 ngx_http_dav_module 支持(增長 PUT、DELETE、MKCOL 建立集合,COPY 和 MOVE 方法)默認狀況下爲關閉,需編譯開啓 |
--with-http_flv_module |
啓用 ngx_http_flv_module 支持(提供尋求內存使用基於時間的偏移量文件) |
--with-http_gzip_static_module |
啓用 ngx_http_gzip_static_module 支持(在線實時壓縮輸出數據流) |
--with-http_random_index_module |
啓用 ngx_http_random_index_module 支持(從目錄中隨機挑選一個目錄索引) |
--with-http_secure_link_module |
啓用 ngx_http_secure_link_module 支持(計算和檢查要求所需的安全連接網址) |
--with-http_degradation_module |
啓用 ngx_http_degradation_module 支持(容許在內存不足的狀況下返回204或444碼) |
--with-http_stub_status_module |
啓用 ngx_http_stub_status_module 支持(獲取 Nginx 自上次啓動以來的工做狀態) |
--without-http_charset_module |
禁用 ngx_http_charset_module 支持(從新編碼 WEB 頁面,但只能是一個方向--服務器端到客戶端,而且只有一個字節的編碼能夠被從新編碼) |
--without-http_gzip_module |
禁用 ngx_http_gzip_module 支持(該模塊同 --with-http_gzip_static_module 功能同樣) |
--without-http_ssi_module |
禁用 ngx_http_ssi_module 支持(該模塊提供了一個在輸入端處理處理服務器包含文件(SSI)的過濾器,目前支持 SSI 命令的列表是不完整的) |
--without-http_userid_module |
禁用 ngx_http_userid_module 支持(該模塊用來處理用來肯定客戶端後續請求的 cookie ) |
--without-http_access_module |
禁用 ngx_http_access_module 支持(該模塊提供了一個簡單的基於主機的訪問控制。容許/拒絕基於 IP 地址) |
--without-http_auth_basic_module |
禁用 ngx_http_auth_basic_module(該模塊是可使用用戶名和密碼基於 HTTP 基本認證方法來保護你的站點或其部份內容) |
--without-http_autoindex_module |
禁用 ngx_http_autoindex_module 支持(該模塊用於自動生成目錄列表,只在 ngx_http_index_module 模塊未找到索引文件時發出請求。) |
--without-http_geo_module |
禁用 ngx_http_geo_module 支持(建立一些變量,其值依賴於客戶端的IP地址) |
--without-http_map_module |
禁用 ngx_http_map_module 支持(使用任意的鍵/值對設置配置變量) |
--without-http_split_clients_module |
禁用 ngx_http_split_clients_module 支持(該模塊用來基於某些條件劃分用戶。條件如:ip地址、報頭、cookies等等) |
--without-http_referer_module |
禁用 ngx_http_referer_module支持(該模塊用來過濾請求,拒絕報頭中 Referer 值不正確的請求) |
--without-http_rewrite_module |
禁用 ngx_http_rewrite_module ,連接重寫 |
--without-http_proxy_module |
禁用 ngx_http_proxy_module 支持(有關代理服務器) |
--without-http_fastcgi_module |
禁用 ngx_http_fastcgi_module 支持(該模塊容許 Nginx 與 FastCGI 進程交互,並經過傳遞參數來控制 FastCGI 進程工做。 )FastCGI 一個常駐型的公共網關接口。 |
--without-http_uwsgi_module |
禁用 ngx_http_uwsgi_module 支持(該模塊用來醫用uwsgi協議,uWSGI服務器相關) |
--without-http_scgi_module |
禁用 ngx_http_scgi_module支持 |
--without-http_memcached_module |
禁用 ngx_http_memcached_module 支持(該模塊用來提供簡單的緩存,以提升系統效率) |
-without-http_limit_zone_module |
禁用 ngx_http_limit_zone_module 支持(該模塊能夠針對條件,進行會話的併發鏈接數控制) |
--without-http_limit_req_module |
禁用 ngx_http_limit_req_module 支持(該模塊容許你對於一個地址進行請求數量的限制用一個給定的session或一個特定的事件) |
--without-http_empty_gif_module |
禁用 ngx_http_empty_gif_module 支持(該模塊在內存中常駐了一個1*1的透明GIF圖像,能夠被很是快速的調用) |
--without-http_browser_module |
禁用 ngx_http_browser_module 支持 |
--without-http_upstream_ip_hash_module |
禁用 ngx_http_upstream_ip_hash_module 支持(該模塊用於簡單的負載均衡) |
--with-http_perl_module |
啓用 ngx_http_perl_module 支持(該模塊使nginx能夠直接使用perl或經過ssi調用perl) |
--with-perl_modules_path= |
設定 perl 模塊路徑 |
--http-log-path= |
設定 access log 路徑 |
--http-client-body-temp-path= |
設定 HTTP 客戶端請求臨時文件路徑 |
--http-proxy-temp-path= |
設定 HTTP 代理臨時文件路徑 |
--http-fastcgi-temp-path= |
設定 HTTP Fastcgi 臨時文件路徑 |
--http-uwsgi-temp-path= |
設定 HTTP uwsgi 臨時文件路徑 |
--http-scgi-temp-path= |
設定 HTTP scgi 臨時文件路徑 |
--without-http |
禁用 HTTP server 功能 |
--without-http-cache |
禁用 HTTP Cache 功能 |
--with-mail |
啓用 POP3/IMAP4/SMTP 代理模塊支持 |
--with-mail_ssl_module |
啓用 ngx_mail_ssl_module 支持 |
--without-mail_pop3_module |
禁用 POP3 協議 |
--without-mail_imap_module |
禁用 IMAP 協議 |
--without-mail_smtp_module |
禁用 SMTP 協議 |
--with-google_perftools_module |
啓用 ngx_google_perftools_module 支持(調試用,剖析程序性能瓶頸) |
--with-cpp_test_module |
啓用 ngx_cpp_test_module 支持 |
make && make install
[root@web02 nginx-1.18.0]# make && make install
在瀏覽器中輸入http://IP地址:80
,IP是你主機的IP地址
參考地址
https://xuexb.github.io/learn-nginx/guide/linux-install.html