Alpine是一个小型的linux系统,官方docker镜像只有不到5MB,非常适合作为容器镜像。

Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and Busybox.

A minimal Docker image based on Alpine Linux with a complete package index and only 5 MB in size!

为了更好地了解alpine,我在虚拟机上安装了一个本地alpine。

上官网下载一个标准STANDARD镜像。创建一个虚拟机,我用的 VMWare Fusion,挂载好下载的iso镜像。

然后启动就可以了,不过这时信息没有存盘,需要使用安装脚本安装系统到磁盘。安装过程其实很简单,初次使用,最重要的是要知道有这个安装脚本。

安装脚本叫做 setup-alpine,其实仔细看的话,系统每次启动和登陆的时候都会有提示。

安装系统细节就不说了,如果有疑问可查官方文档。安装完成后,需要重启系统。重启之后,就是从磁盘启动的了。

下面具体说说如何使用:

1、配置安装源。

# vim /etc/apk/repositories
https://mirrors.ustc.edu.cn/alpine/edge/main
https://mirrors.ustc.edu.cn/alpine/edge/community
https://mirrors.ustc.edu.cn/alpine/edge/testing

2、安装ssh服务。Alpine使用的包管理工具叫 apk。服务管理系统叫 OpenRC。

# apk update
# apk add openssh
# rc-service sshd start
# rc-update add sshd

3、修改sshd配置文件,允许root登录。

# vim /etc/ssh/sshd_config
PermitRootLogin yes # service sshd restart

这时就可以使用终端远程登陆了。

4、安装用户管理工具,修改root用户的shell为bash,默认使用的是ash。

# apk add shadow

# usermod -s /bin/bash root

5、安装常用工具。

# apk add vim bash bash-completion

6、设置常用别名。

# vim /etc/profile
export LS_OPTIONS='--color=auto'
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

7、其实在testing源里面,已经有现成的tengine安装包了。不过这里我会测试手动编译,不会直接使用安装包。

# apk policy tengine
tengine policy:
2.1.0-r4:
https://mirrors.ustc.edu.cn/alpine/edge/testing

8、如何查看安装包包含哪些文件。有两种方法,不过都只能查看已经安装的包。

# apk manifest tengine | awk '{print $2}'
etc/tengine/scgi_params
etc/tengine/fastcgi_params
etc/tengine/tengine.conf
etc/tengine/uwsgi_params
etc/tengine/fastcgi.conf
etc/tengine/mime.types
etc/tengine/koi-win
etc/tengine/mime.types.default
etc/tengine/koi-utf
etc/tengine/browsers
etc/tengine/uwsgi_params.default
etc/tengine/scgi_params.default
etc/tengine/module_stubs
etc/tengine/nginx.conf.default
etc/tengine/fastcgi_params.default
etc/tengine/win-utf
etc/tengine/fastcgi.conf.default
etc/logrotate.d/tengine
etc/init.d/tengine
usr/sbin/nginx
usr/sbin/dso_tool
usr/html/index.html
usr/html/50x.html
usr/share/licenses/tengine/LICENSE
# apk info -a tengine | grep -v \.h
tengine-2.1.0-r4 description: tengine-2.1.0-r4 webpage:
http://tengine.taobao.org/ tengine-2.1.0-r4 installed size:
1519616 tengine-2.1.0-r4 depends on:
so:libc.musl-x86_64.so.1
so:libcrypto.so.42
so:libpcre.so.1
so:libssl.so.44
so:libz.so.1 tengine-2.1.0-r4 provides:
cmd:dso_tool
cmd:nginx tengine-2.1.0-r4 is required by: tengine-2.1.0-r4 contains:
etc/tengine/scgi_params
etc/tengine/fastcgi_params
etc/tengine/tengine.conf
etc/tengine/uwsgi_params
etc/tengine/fastcgi.conf
etc/tengine/mime.types
etc/tengine/koi-win
etc/tengine/mime.types.default
etc/tengine/koi-utf
etc/tengine/browsers
etc/tengine/uwsgi_params.default
etc/tengine/scgi_params.default
etc/tengine/module_stubs
etc/tengine/nginx.conf.default
etc/tengine/fastcgi_params.default
etc/tengine/win-utf
etc/tengine/fastcgi.conf.default
etc/logrotate.d/tengine
etc/init.d/tengine
usr/sbin/nginx
usr/sbin/dso_tool tengine-2.1.0-r4 triggers: tengine-2.1.0-r4 affects auto-installation of: tengine-2.1.0-r4 replaces: tengine-2.1.0-r4 license:
Custom

9、安装开发组件。

# apk add alpine-sdk
(1/26) Installing fakeroot (1.22-r0)
(2/26) Installing sudo (1.8.22-r2)
(3/26) Installing pax-utils (1.2.2-r1)
(4/26) Installing libressl2.6-libtls (2.6.4-r0)
(5/26) Installing libressl (2.6.4-r0)
(6/26) Installing libattr (2.4.47-r6)
(7/26) Installing attr (2.4.47-r6)
(8/26) Installing tar (1.30-r0)
(9/26) Installing patch (2.7.6-r1)
(10/26) Installing lzip (1.19-r2)
(11/26) Installing abuild (3.1.0-r4)
Executing abuild-3.1.0-r4.pre-install
(12/26) Installing libmagic (5.32-r0)
(13/26) Installing file (5.32-r0)
(14/26) Installing g++ (6.4.0-r6)
(15/26) Installing fortify-headers (0.9-r0)
(16/26) Installing build-base (0.5-r1)
(17/26) Installing lz4-libs (1.8.1.2-r0)
(18/26) Installing lzo (2.10-r2)
(19/26) Installing squashfs-tools (4.3-r4)
(20/26) Installing libburn (1.4.8-r0)
(21/26) Installing libedit (20170329.3.1-r3)
(22/26) Installing libacl (2.2.52-r4)
(23/26) Installing libisofs (1.4.8-r0)
(24/26) Installing libisoburn (1.4.8-r0)
(25/26) Installing xorriso (1.4.8-r0)
(26/26) Installing alpine-sdk (0.5-r0)

其中,build-base包含gcc,libc,make,g++。

# apk info -a build-base

build-base-0.5-r1 webpage:
http://dev.alpinelinux.org/cgit build-base-0.5-r1 installed size:
4096 build-base-0.5-r1 depends on:
binutils
file
gcc
g++
make
libc-dev
fortify-headers

10、编译安装tengine。这里我加了ldap模块。

# apk add libressl-dev openldap-dev zlib-dev pcre-dev
# mkdir /usr/local/src
# cd /usr/local/src
# git clone https://github.com/kvspb/nginx-auth-ldap.git
# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
# tar xvf tengine-2.2.0.tar.gz
# cd tengine-2.2.0/
# ./configure --prefix=/usr/local/nginx --with-http_reqstat_module=shared --add-module=../nginx-auth-ldap
# make -j 2
# make install
# make dso_install

11、安装supervisor。

# apk add supervisor

修改supervisor的配置文件。

# vim /etc/supervisord.conf

[unix_http_server]
file=/run/supervisord.sock ; (the path to the socket file) [supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
environment=LC_ALL=en_US.UTF-8,LANG=en_US.UTF-8,LANGUAGE=en_US.UTF-8 [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL for a unix socket [program:nginx-app]
command = /usr/local/nginx/sbin/nginx

这里需要手动创建日志目录,不然supervisord无法启动。算是一个坑。

# mkdir /var/log/supervisor
# service start supervisord
# supervisorctl
nginx-app RUNNING pid 33479, uptime 0:00:02


补充

# apk --help

apk-tools 2.9.1, compiled for x86_64.

usage: apk COMMAND [options] [ARGS]

The following commands are available:
add Add PACKAGEs to 'world' and install (or upgrade) them, while ensuring that all dependencies are met
del Remove PACKAGEs from 'world' and uninstall them
fix Repair package or upgrade it without modifying main dependencies
update Update repository indexes from all remote repositories
info Give detailed information about PACKAGEs or repositories
search Search package by PATTERNs or by indexed dependencies
upgrade Upgrade currently installed packages to match repositories
cache Download missing PACKAGEs to cache and/or delete unneeded files from cache
version Compare package versions (in installed database vs. available) or do tests on literal version strings
index Create repository index file from FILEs
fetch Download PACKAGEs from global repositories to a local directory
audit Audit the directories for changes
verify Verify package integrity and signature
dot Generate graphviz graphs
policy Show repository policy for packages
stats Show statistics about repositories and installations
manifest Show checksums of package contents Global options:
-h, --help Show generic help or applet specific help
-p, --root DIR Install packages to DIR
-X, --repository REPO Use packages from REPO
-q, --quiet Print less information
-v, --verbose Print more information (can be doubled)
-i, --interactive Ask confirmation for certain operations
-V, --version Print program version and exit
-f, --force Enable selected --force-* (deprecated)
--force-binary-stdout Continue even if binary data is to be output
--force-broken-world Continue even if 'world' cannot be satisfied
--force-non-repository Continue even if packages may be lost on reboot
--force-old-apk Continue even if packages use unsupported features
--force-overwrite Overwrite files in other packages
--force-refresh Do not use cached files (local or from proxy)
-U, --update-cache Alias for --cache-max-age 60
--progress Show a progress bar
--progress-fd FD Write progress to fd
--no-progress Disable progress bar even for TTYs
--purge Delete also modified configuration files (pkg removal) and uninstalled packages from cache (cache clean)
--allow-untrusted Install packages with untrusted signature or no signature
--wait TIME Wait for TIME seconds to get an exclusive repository lock before failing
--keys-dir KEYSDIR Override directory of trusted keys
--repositories-file REPOFILE Override repositories file
--no-network Do not use network (cache is still used)
--no-cache Do not use any local cache path
--cache-dir CACHEDIR Override cache directory
--cache-max-age AGE Maximum AGE (in minutes) for index in cache before refresh
--arch ARCH Use architecture with --root
--print-arch Print default arch and exit This apk has coffee making abilities.

最后这句造咖啡的能力好奇特意查了一下,真的有这个feature...不过没什么用。

# apk fetch coffee
Go and fetch your own coffee.

alpine编译安装tengine,并使用supervisor启动的更多相关文章

  1. debian7编译安装tengine添加lua和ldap模块

    1.安装开发环境 # aptitute update # aptitude install -y build-essential # aptitude install -y libldap2-dev ...

  2. CentOS 7编译安装Tengine+PHP+MariaDB全程笔记

    安装环境:CentOS7 3.10.0-693.5.2.el7.x86_64 准备源码包: pcre-8.41.tar.gz openssl-1.0.1h.tar.gz zlib-1.2.11.tar ...

  3. centos7 yum安装nginx和 编译安装tengine

    说明 我这里给大家演示一下如何安装nginx,nginx我就不多介绍了,然后我再说一点就是,安装的两种方法都可以,编译安装和yum安装,我不能每个都演示两遍呀,所以看到我这博客的你,学会举一反三好吧? ...

  4. CentOS7 源码编译安装Tengine

    简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.它的目的是打造一个高效.安全的Web平台. 发展 Tengine的性能和 ...

  5. CentOS 7.2编译安装Tengine

    Tengine官网上有个非常简单的教程,中间并未涉及到一些常用的设置,所以仅供参考.一下午为本人的安装步骤及过程. 配置firewalld,iptables,关闭SELINUX 1.安装必要的编译环境 ...

  6. Mysql 编译安装并使用自定义用户启动

    本文基于 Redhat Linux 6.7 的环境,Mysql 版本为 5.5.37 安装前的检查 必备的组件,如果没有使用 yum 进行安装,可以使用网上的源,也可以使用本地光盘作为 Yum 源. ...

  7. 源码编译安装nginx及设置开机启动项

    1.上传nginx文档:解压到/data目录下,并安装依赖包tar xf nginx-1.20.1.tar.gz -C /data/cd /data/nginx-1.20.1/ && ...

  8. apache编译安装完成后的服务启动设置

    Apache安装后可通过其安装路径的bin目录下的apachectl脚本控制服务的启动和停止.本例中apache安装在/usr/local/apache-2.2.6,服务控制脚本为: /usr/loc ...

  9. CentOS 6.4编译安装淘宝web服务器Tengine

    Tengine 是由淘宝核心系统部基于Nginx开发的Web服务器,它在Nginx的基础上,针对大访问量网站的需求,添加了很多功能和特性.Tengine的性能和稳定性已经在大型的网站如淘宝网,淘宝商城 ...

随机推荐

  1. go语言之行--基础部分

    一.数据类型 布尔型 布尔类型 - 由两个预定义常量组成:true.false,默认值为false package main import "fmt" func main() { ...

  2. 20155207 实验5 MSF基础应用

    20155207 实验5 MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode exploit:让攻击方式能够发挥作用的通道,更像是没有子弹的枪,提供了攻击方 ...

  3. Exp7:网络欺诈防范

    Exp7:网络欺诈防范 基础问题回答 通常在什么场景下容易受到DNS spoof攻击? 答:同一局域网下,以及各种公共网络. 在日常生活工作中如何防范以上两攻击方法? 答: 使用最新版本的DNS服务器 ...

  4. 20155321 《网络攻防》 Exp9 Web安全基础

    20155321 <网络攻防> Exp9 Web安全基础 基础问题 SQL注入攻击原理,如何防御 原理:在事先定义好的SQL语句的结尾上添加额外的SQL语句(感觉一般是或上一个永真式),以 ...

  5. Oracle出现与并行相关的ORA-00600时的调查方法

    出现了 ORA-00600[kxfpqsod_qc_sod], 如何调查呢? 例如:从trace 文件的 Call Stack,可以看到 Error: ORA-600 [kxfpqsod_qc_sod ...

  6. 未能正确加载包“Microsoft.Data.Entity.Design.Package.MicrosoftDataEntityDesignPackage(转)

    版权声明:作者:jiankunking 出处:http://blog.csdn.net/jiankunking 本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显 ...

  7. idea Cannot Resolve Symbol 问题解决

    总结:要多根据有问题的提示来进行百度搜索,这一次我就是搜索了 idea 提示的错误信息 Cannot Resolve Symbol ,才找到的解决方案,所以说出现问题,如果不是很复杂的场景或者原因很多 ...

  8. [UOJ#461]新年的Dog划分[二分图染色、二分]

    题意 给你一张无向连通图,你并不知道有哪些边,你首先要回答这张图是否是二分图,如果是,回答这张图黑白染色过后的任意一个点集.你需要在2000次询问内找到结果,每次你可以询问原图中一个边集删掉后是否还连 ...

  9. IT高管和易筋经的故事

    老板是我非常敬重的前领导之一,他的一些管理风格,也影响了后来我对技术团队的管理. 理想企业 什么是程序员理想的IT企业?公司里面有良好的同事关系,合理的产品需求和开发进度,最好老板懂点编程,这样公司更 ...

  10. Spring Boot (十四): Spring Boot 整合 Shiro-登录认证和权限管理

    这篇文章我们来学习如何使用 Spring Boot 集成 Apache Shiro .安全应该是互联网公司的一道生命线,几乎任何的公司都会涉及到这方面的需求.在 Java 领域一般有 Spring S ...