[{"data":1,"prerenderedAt":543},["ShallowReactive",2],{"content-query-wEQLHgOiAO":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"category":5,"createdAt":10,"updatedAt":11,"body":12,"_type":537,"_id":538,"_source":539,"_file":540,"_stem":541,"_extension":542},"/article/server/alpine-apk-command-and-manual-install-specific-version-of-package","server",false,"","Alpine Linux 包管理工具指令用法與手動安裝特定版本套件","Alpine 是一個輕量級的 Linux 發行版本，同時提供包管理工具 apk，以下介紹 apk 相關操作指令，以 curl 套件為例:","2022-09-30","2022-12-05",{"type":13,"children":14,"toc":528},"root",[15,47,53,80,85,104,109,119,143,161,166,189,194,217,222,246,251,263,319,484,498,517,522],{"type":16,"tag":17,"props":18,"children":19},"element","p",{},[20,23,30,32,37,39,45],{"type":21,"value":22},"text","Alpine 是一個輕量級的 Linux 發行版本，同時提供包管理工具 ",{"type":16,"tag":24,"props":25,"children":27},"code",{"className":26},[],[28],{"type":21,"value":29},"apk",{"type":21,"value":31},"，以下介紹 ",{"type":16,"tag":24,"props":33,"children":35},{"className":34},[],[36],{"type":21,"value":29},{"type":21,"value":38}," 相關操作指令，以 ",{"type":16,"tag":24,"props":40,"children":42},{"className":41},[],[43],{"type":21,"value":44},"curl",{"type":21,"value":46}," 套件為例:",{"type":16,"tag":48,"props":49,"children":51},"h2",{"id":50},"更新鏡像源",[52],{"type":21,"value":50},{"type":16,"tag":54,"props":55,"children":59},"pre",{"className":56,"code":57,"language":58,"meta":7,"style":7},"language-sh shiki shiki-themes material-theme-palenight","apk update\n","sh",[60],{"type":16,"tag":24,"props":61,"children":62},{"__ignoreMap":7},[63],{"type":16,"tag":64,"props":65,"children":68},"span",{"class":66,"line":67},"line",1,[69,74],{"type":16,"tag":64,"props":70,"children":72},{"style":71},"--shiki-default:#FFCB6B",[73],{"type":21,"value":29},{"type":16,"tag":64,"props":75,"children":77},{"style":76},"--shiki-default:#C3E88D",[78],{"type":21,"value":79}," update\n",{"type":16,"tag":48,"props":81,"children":83},{"id":82},"升級系統已安裝套件包",[84],{"type":21,"value":82},{"type":16,"tag":54,"props":86,"children":88},{"className":56,"code":87,"language":58,"meta":7,"style":7},"apk upgrade\n",[89],{"type":16,"tag":24,"props":90,"children":91},{"__ignoreMap":7},[92],{"type":16,"tag":64,"props":93,"children":94},{"class":66,"line":67},[95,99],{"type":16,"tag":64,"props":96,"children":97},{"style":71},[98],{"type":21,"value":29},{"type":16,"tag":64,"props":100,"children":101},{"style":76},[102],{"type":21,"value":103}," upgrade\n",{"type":16,"tag":48,"props":105,"children":107},{"id":106},"搜尋可用套件",[108],{"type":21,"value":106},{"type":16,"tag":110,"props":111,"children":112},"ol",{},[113],{"type":16,"tag":114,"props":115,"children":116},"li",{},[117],{"type":21,"value":118},"使用指令查找:",{"type":16,"tag":54,"props":120,"children":122},{"className":56,"code":121,"language":58,"meta":7,"style":7},"apk search curl\n",[123],{"type":16,"tag":24,"props":124,"children":125},{"__ignoreMap":7},[126],{"type":16,"tag":64,"props":127,"children":128},{"class":66,"line":67},[129,133,138],{"type":16,"tag":64,"props":130,"children":131},{"style":71},[132],{"type":21,"value":29},{"type":16,"tag":64,"props":134,"children":135},{"style":76},[136],{"type":21,"value":137}," search",{"type":16,"tag":64,"props":139,"children":140},{"style":76},[141],{"type":21,"value":142}," curl\n",{"type":16,"tag":110,"props":144,"children":146},{"start":145},2,[147],{"type":16,"tag":114,"props":148,"children":149},{},[150,152],{"type":21,"value":151},"或是從官網查找在 Alpine 不同版本下有支援的套件與版本:\n",{"type":16,"tag":153,"props":154,"children":159},"a",{"href":155,"rel":156,"target":158},"https://pkgs.alpinelinux.org/packages",[157],"nofollow","_blank",[160],{"type":21,"value":155},{"type":16,"tag":48,"props":162,"children":164},{"id":163},"安裝套件",[165],{"type":21,"value":163},{"type":16,"tag":54,"props":167,"children":169},{"className":56,"code":168,"language":58,"meta":7,"style":7},"apk add curl\n",[170],{"type":16,"tag":24,"props":171,"children":172},{"__ignoreMap":7},[173],{"type":16,"tag":64,"props":174,"children":175},{"class":66,"line":67},[176,180,185],{"type":16,"tag":64,"props":177,"children":178},{"style":71},[179],{"type":21,"value":29},{"type":16,"tag":64,"props":181,"children":182},{"style":76},[183],{"type":21,"value":184}," add",{"type":16,"tag":64,"props":186,"children":187},{"style":76},[188],{"type":21,"value":142},{"type":16,"tag":48,"props":190,"children":192},{"id":191},"刪除套件",[193],{"type":21,"value":191},{"type":16,"tag":54,"props":195,"children":197},{"className":56,"code":196,"language":58,"meta":7,"style":7},"apk del curl\n",[198],{"type":16,"tag":24,"props":199,"children":200},{"__ignoreMap":7},[201],{"type":16,"tag":64,"props":202,"children":203},{"class":66,"line":67},[204,208,213],{"type":16,"tag":64,"props":205,"children":206},{"style":71},[207],{"type":21,"value":29},{"type":16,"tag":64,"props":209,"children":210},{"style":76},[211],{"type":21,"value":212}," del",{"type":16,"tag":64,"props":214,"children":215},{"style":76},[216],{"type":21,"value":142},{"type":16,"tag":48,"props":218,"children":220},{"id":219},"列出所有已安裝套件與版本",[221],{"type":21,"value":219},{"type":16,"tag":54,"props":223,"children":225},{"className":56,"code":224,"language":58,"meta":7,"style":7},"apk list -I\n",[226],{"type":16,"tag":24,"props":227,"children":228},{"__ignoreMap":7},[229],{"type":16,"tag":64,"props":230,"children":231},{"class":66,"line":67},[232,236,241],{"type":16,"tag":64,"props":233,"children":234},{"style":71},[235],{"type":21,"value":29},{"type":16,"tag":64,"props":237,"children":238},{"style":76},[239],{"type":21,"value":240}," list",{"type":16,"tag":64,"props":242,"children":243},{"style":76},[244],{"type":21,"value":245}," -I\n",{"type":16,"tag":48,"props":247,"children":249},{"id":248},"手動安裝套件特定版本",[250],{"type":21,"value":248},{"type":16,"tag":17,"props":252,"children":253},{},[254,256,261],{"type":21,"value":255},"有時候在專案 Alpine 版本不更動的情況下，會有需求要求套件升級，但需求升級版本已經超過 Alpine 該版本所提供的套件版本，除了 Alpine 外其他 OS 像是 CentOS 等也會有類似的問題可如下類似方式解決，以安裝 ",{"type":16,"tag":24,"props":257,"children":259},{"className":258},[],[260],{"type":21,"value":44},{"type":21,"value":262}," 特定版本為例:",{"type":16,"tag":110,"props":264,"children":265},{},[266,295,314],{"type":16,"tag":114,"props":267,"children":268},{},[269,271,277,279,285,287,293],{"type":21,"value":270},"先用上面教的使用指令查找版本，以 ",{"type":16,"tag":24,"props":272,"children":274},{"className":273},[],[275],{"type":21,"value":276},"alpine3.12",{"type":21,"value":278}," 的版本是到 ",{"type":16,"tag":24,"props":280,"children":282},{"className":281},[],[283],{"type":21,"value":284},"curl-7.79.1-r1",{"type":21,"value":286},"，但我們要裝 ",{"type":16,"tag":24,"props":288,"children":290},{"className":289},[],[291],{"type":21,"value":292},"7.85.0-r0",{"type":21,"value":294}," 這版",{"type":16,"tag":114,"props":296,"children":297},{},[298,300,306,308],{"type":21,"value":299},"從官網查找所需版本壓縮檔路徑\n",{"type":16,"tag":153,"props":301,"children":304},{"href":302,"rel":303,"target":158},"https://curl.se/download.html",[157],[305],{"type":21,"value":302},{"type":21,"value":307},"\n這個是我要的版本: ",{"type":16,"tag":153,"props":309,"children":312},{"href":310,"rel":311,"target":158},"https://curl.se/download/curl-7.85.0.tar.gz",[157],[313],{"type":21,"value":310},{"type":16,"tag":114,"props":315,"children":316},{},[317],{"type":21,"value":318},"指令安裝套件",{"type":16,"tag":54,"props":320,"children":324},{"className":321,"code":322,"language":323,"meta":7,"style":7},"language-bash shiki shiki-themes material-theme-palenight","wget https://curl.se/download/curl-7.85.0.tar.gz && \\\ntar -xvf curl-7.85.0.tar.gz && cd curl-7.85.0 && \\\n./configure --with-openssl && make && make install; \\\ncd ../ && rm -rf curl-7.85.0*; \\\n","bash",[325],{"type":16,"tag":24,"props":326,"children":327},{"__ignoreMap":7},[328,353,394,439],{"type":16,"tag":64,"props":329,"children":330},{"class":66,"line":67},[331,336,341,347],{"type":16,"tag":64,"props":332,"children":333},{"style":71},[334],{"type":21,"value":335},"wget",{"type":16,"tag":64,"props":337,"children":338},{"style":76},[339],{"type":21,"value":340}," https://curl.se/download/curl-7.85.0.tar.gz",{"type":16,"tag":64,"props":342,"children":344},{"style":343},"--shiki-default:#89DDFF",[345],{"type":21,"value":346}," &&",{"type":16,"tag":64,"props":348,"children":350},{"style":349},"--shiki-default:#BABED8",[351],{"type":21,"value":352}," \\\n",{"type":16,"tag":64,"props":354,"children":355},{"class":66,"line":145},[356,361,366,371,375,381,386,390],{"type":16,"tag":64,"props":357,"children":358},{"style":71},[359],{"type":21,"value":360},"tar",{"type":16,"tag":64,"props":362,"children":363},{"style":76},[364],{"type":21,"value":365}," -xvf",{"type":16,"tag":64,"props":367,"children":368},{"style":76},[369],{"type":21,"value":370}," curl-7.85.0.tar.gz",{"type":16,"tag":64,"props":372,"children":373},{"style":343},[374],{"type":21,"value":346},{"type":16,"tag":64,"props":376,"children":378},{"style":377},"--shiki-default:#82AAFF",[379],{"type":21,"value":380}," cd",{"type":16,"tag":64,"props":382,"children":383},{"style":76},[384],{"type":21,"value":385}," curl-7.85.0",{"type":16,"tag":64,"props":387,"children":388},{"style":343},[389],{"type":21,"value":346},{"type":16,"tag":64,"props":391,"children":392},{"style":349},[393],{"type":21,"value":352},{"type":16,"tag":64,"props":395,"children":397},{"class":66,"line":396},3,[398,403,408,412,417,421,425,430,435],{"type":16,"tag":64,"props":399,"children":400},{"style":71},[401],{"type":21,"value":402},"./configure",{"type":16,"tag":64,"props":404,"children":405},{"style":76},[406],{"type":21,"value":407}," --with-openssl",{"type":16,"tag":64,"props":409,"children":410},{"style":343},[411],{"type":21,"value":346},{"type":16,"tag":64,"props":413,"children":414},{"style":71},[415],{"type":21,"value":416}," make",{"type":16,"tag":64,"props":418,"children":419},{"style":343},[420],{"type":21,"value":346},{"type":16,"tag":64,"props":422,"children":423},{"style":71},[424],{"type":21,"value":416},{"type":16,"tag":64,"props":426,"children":427},{"style":76},[428],{"type":21,"value":429}," install",{"type":16,"tag":64,"props":431,"children":432},{"style":343},[433],{"type":21,"value":434},";",{"type":16,"tag":64,"props":436,"children":437},{"style":349},[438],{"type":21,"value":352},{"type":16,"tag":64,"props":440,"children":442},{"class":66,"line":441},4,[443,448,453,457,462,467,471,476,480],{"type":16,"tag":64,"props":444,"children":445},{"style":377},[446],{"type":21,"value":447},"cd",{"type":16,"tag":64,"props":449,"children":450},{"style":76},[451],{"type":21,"value":452}," ../",{"type":16,"tag":64,"props":454,"children":455},{"style":343},[456],{"type":21,"value":346},{"type":16,"tag":64,"props":458,"children":459},{"style":71},[460],{"type":21,"value":461}," rm",{"type":16,"tag":64,"props":463,"children":464},{"style":76},[465],{"type":21,"value":466}," -rf",{"type":16,"tag":64,"props":468,"children":469},{"style":76},[470],{"type":21,"value":385},{"type":16,"tag":64,"props":472,"children":473},{"style":349},[474],{"type":21,"value":475},"*",{"type":16,"tag":64,"props":477,"children":478},{"style":343},[479],{"type":21,"value":434},{"type":16,"tag":64,"props":481,"children":482},{"style":349},[483],{"type":21,"value":352},{"type":16,"tag":110,"props":485,"children":486},{"start":441},[487],{"type":16,"tag":114,"props":488,"children":489},{},[490,492],{"type":21,"value":491},"驗證安裝版本為 ",{"type":16,"tag":24,"props":493,"children":495},{"className":494},[],[496],{"type":21,"value":497},"7.85.0",{"type":16,"tag":54,"props":499,"children":501},{"className":56,"code":500,"language":58,"meta":7,"style":7},"curl --version\n",[502],{"type":16,"tag":24,"props":503,"children":504},{"__ignoreMap":7},[505],{"type":16,"tag":64,"props":506,"children":507},{"class":66,"line":67},[508,512],{"type":16,"tag":64,"props":509,"children":510},{"style":71},[511],{"type":21,"value":44},{"type":16,"tag":64,"props":513,"children":514},{"style":76},[515],{"type":21,"value":516}," --version\n",{"type":16,"tag":17,"props":518,"children":519},{},[520],{"type":21,"value":521},"這樣就完成了安裝特定版本了。",{"type":16,"tag":523,"props":524,"children":525},"style",{},[526],{"type":21,"value":527},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":145,"depth":145,"links":529},[530,531,532,533,534,535,536],{"id":50,"depth":145,"text":50},{"id":82,"depth":145,"text":82},{"id":106,"depth":145,"text":106},{"id":163,"depth":145,"text":163},{"id":191,"depth":145,"text":191},{"id":219,"depth":145,"text":219},{"id":248,"depth":145,"text":248},"markdown","content:article:server:alpine-apk-command-and-manual-install-specific-version-of-package.md","content","article/server/alpine-apk-command-and-manual-install-specific-version-of-package.md","article/server/alpine-apk-command-and-manual-install-specific-version-of-package","md",1766375573980]