参考
| # 中科大 |
| http://mirrors.ustc.edu.cn/alpine/ |
| https://mirrors.ustc.edu.cn/alpine/v3.15/main/ |
| https://mirrors.ustc.edu.cn/alpine/v3.15/community/ |
| # 阿里云 |
| https://mirrors.aliyun.com/alpine/ |
| https://mirrors.aliyun.com/alpine/latest-stable/community/ |
| https://mirrors.aliyun.com/alpine/latest-stable/main/ |
| # 清华大学 |
| https://mirror.tuna.tsinghua.edu.cn/alpine/ |
| https://mirror.tuna.tsinghua.edu.cn/alpine/latest-stable/ |
| https://mirror.tuna.tsinghua.edu.cn/alpine/last-updated |
| |

Alpine初始化
| # 配置ssh远程登录 |
| vi /etc/ssh/sshd_config |
| PermitRootLogin yes |
| |
| rc-service sshd restart |
| |
| |
| apk add openssh vim bash nginx util-linux bash bash-doc bash-completion curl net-tools |
| |
| |
Alpine linux包管理
| vim /etc/apk/repositories #配置阿里云源 |
| http://mirrors.aliyun.com/alpine/v3.15/main |
| http://mirrors.aliyun.com/alpine/v3.15/community |
| |
| |
| # 更新最新镜像源列表 |
| apk update |
| |
| |
| apk search # 查找所有可用软件包 |
| apk search -v # 查找所用可用软件包及其描述内容 |
| apk search -v ‘包名’ # 通过软件包名称查找软件包 |
| apk search -v -d ‘docker’ # 通过描述文件查找特定的软件包 |
| |
| |
| apk add openssh # 安装一个软件 |
| apk add openssh vim bash nginx # 安装多个软件 |
| apk add --no-cache mysql-client # 不使用本地镜像源缓存,相当于先执行update,再执行add |
| |
| apk info # 列出所有已安装的软件包 |
| apk info -a zlib # 显示完整的软件包信息 |
| apk info --who-owns /usr/sbin/nginx # 显示指定文件属于的包 |
| |
| apk upgrade # 升级所有软件 |
| apk upgrade openssh # 升级指定软件 |
| apk upgrade openssh vim bash nginx # 升级多个软件 |
| apk add --upgrade busybox # 指定升级部分软件包 |
| |
| |
| apk del openssh # 删除一个软件 |
| apk del nginx mysql # 删除多个软件 |
| |
| |
| rc-update # 主要用于不同运行级增加或者删除服务。 |
| rc-status # 主要用于运行级的状态管理。 |
| rc-service # 主用于管理服务的状态 |
| openrc # 主要用于管理不同的运行级。 |
| |
| |
| # 列出所有服务: rc-status -a |
| |
| |
| Alpine常用命令 |
| # 安装vim命令 apk add vim |
| apk add --no-cache openssh # 不使用本地镜像源缓存,相当于先执行update,再执行add |
| apk del openssh # 卸载软件包 |
| |
| |
| # 创建用户 |
| addgroup -g 10001 -S admin # 先指定一个GID组 |
| |
| # 指定一个UID的用户,指定shell,让其属于指定的用户组 |
| adduser admin -u 20001 -D -S -s /bin/bash -G admin |
| |
| deluser admin # 删除用户 |
| |
| |
| # 系统软件 |
| apk add --no-cache vim openssh util-linux bash bash-doc bash-completion curl net-tools |
| |
| |
| # Apline网卡配置 |
| vim /etc/network/interfaces |
| # 配置DHCP |
| auto lo |
| iface lo inet loopback |
| auto eth0 |
| iface eth0 inet dhcp |
| |
| |
| # 配置静态IP |
| auto lo |
| iface lo inet loopback |
| auto eth0 |
| iface eth0 inet static |
| address 10.1.3.200 |
| netmask 255.255.255.0 |
| gateway 10.1.3.3 |
| dns1 114.114.114.114 |
| dns2 8.8.8.8 |
| |
| 重启网络服务 |
| rc-service networking restart |
alpine install nginx
| # Nginx package is available in the Alpine Linux repositories |
| apk update && apk add nginx |
| |
| # Creating new user and group 'www' for nginx |
| adduser -D -g 'Nginx www user' -h /home/www/ www |
| |
| # Create a directory for html files |
| mkdir /www |
| chown -R www:www /var/lib/nginx |
| chown -R www:www /www |
| |
| # Configuration |
| mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf,-bak |
| |
| vim /etc/nginx/nginx.conf |
| user www; |
| worker_processes auto; |
| |
| #error_log /var/log/nginx/error.log warn; |
| #pid /var/run/nginx/nginx.pid; |
| |
| events { |
| worker_connections 1024; |
| } |
| |
| http { |
| include /etc/nginx/mime.types; |
| default_type application/octet-stream; |
| sendfile on; |
| # access_log /var/log/nginx/access.log; |
| keepalive_timeout 3000; |
| autoindex on; # 显示目录 |
| autoindex_exact_size on; # 显示文件大小 |
| autoindex_localtime on; # 显示文件时间 |
| server { |
| listen 80; |
| server_name 192.168.22.32; |
| root /www; |
| index index.html index.htm; |
| charset utf-8; |
| client_max_body_size 32m; |
| error_page 500 502 503 504 /50x.html; |
| location = /50x.html { |
| root /var/lib/nginx/html; |
| } |
| } |
| } |
| |
| |
| |
| # Sample page |
| echo "<h1>The page is Test</h1>" > /www/index.html |
| |
| # Test configuration |
| nginx -t |
| |
| # Start Nginx |
| rc-service nginx {start | reload | restart | stop | status} |
| ps aux | grep "[n|N]ginx" |
| |
| |
| # Boot on self-starting |
| rc-update add nginx default |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!