The use of the alpine container apk command - Programmer Sought
replace source
# 阿里的
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
# 中科大的
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
search package
The search uses search
subcommands, examples are as follows:
apk search php8
php8-imap-8.0.9-r0
php8-ftp-8.0.9-r0
php8-pspell-8.0.9-r0
php8-phar-8.0.9-r0
php8-pecl-imagick-dev-3.5.0-r0
php8-litespeed-8.0.9-r0
php8-pecl-vips-1.0.12-r0
php8-dba-8.0.9-r0
A lot of results will be displayed, and then you can install it directly according to the name.
Install
The installation uses subcommands add
, not install
the following example:
apk add php8-ftp
fetch https://mirrors.aliyun.com/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://mirrors.aliyun.com/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/1) Installing php8-ftp (8.0.9-r0)
OK: 118 MiB in 96 packages
The information displayed during the installation process is also very concise and clear
Query package information
The query uses subcommands info
, examples are as follows:
apk info -a php8-ftp
php8-ftp-8.0.9-r0 description:
PHP8 extension: FTP
php8-ftp-8.0.9-r0 webpage:
https://www.php.net/
php8-ftp-8.0.9-r0 installed size:
104 KiB
php8-ftp-8.0.9-r0 depends on:
php8-common
so:libc.musl-x86_64.so.1
so:libcrypto.so.1.1
so:libssl.so.1.1
php8-ftp-8.0.9-r0 provides:
php-ftp
php8-ftp-8.0.9-r0 is required by:
php8-ftp-8.0.9-r0 contains:
etc/php8/conf.d/00_ftp.ini
usr/lib/php8/modules/ftp.so
php8-ftp-8.0.9-r0 triggers:
php8-ftp-8.0.9-r0 has auto-install rule:
php8-ftp-8.0.9-r0 affects auto-installation of:
php8-ftp-8.0.9-r0 replaces:
php8-ftp-8.0.9-r0 license:
PHP-3.01 BSD-3-Clause LGPL-2.0-or-later MIT Zend-2.0
Use -a
the option to display complete information, including its required dependencies, its size, file storage location in the package, project address, provided libraries, etc., in great detail.
remove
Removal uses subcommands del
, examples are as follows:
apk del php8-ftp
(1/1) Purging php8-ftp (8.0.9-r0)
OK: 118 MiB in 95 packages
The above are a few basic operation commands of the apk tool
User management useradd function download
apk add shadow
Detailed explanation of useradd command, linux groupadd command
install nginx
apk add nginx
create nginx user
adduser -D -g 'nginx' nginx
nginx -t Check it out, prompt
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/run/nginx/nginx.pid" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
solve:
chown -R nginx:nginx /var/lib/nginx
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
mkdir -p /run/nginx/