标签:image 下载 nss entry data 高并发 str 开机自启 ln -s
nginx有四个版本,开源nginx版,商业nginx plus版,淘宝tengine分支版,和openresty扩展板
其中商业版收费,淘宝版是阿里针对nginx的高并发二次开发的项目,而扩展版和淘宝版有着异曲同工之妙,个人感觉扩展板性能更强悍一些。
1使用dockerfile制作一个nginx扩展板的镜像:
1 mkdir -p ruanjian/dockerfile/mynginx 2 3 cd ruanjian/dockerfile/mynginx 4 5 touch nginx.dockerfile 6 7 chmod 777 nginx.dockerfile 8 9 vim nginx.dockerfile 10 11 docker build -f /root/ruanjian/dockerfile/mynginx/nginx.dockerfile -t nginx:1.0 . 12 13 docker images 14 15 docker run --name nginx -h nginx -p 80:80 -v /opt/data/apps/nginx/conf:/usr/local/nginx/conf -d nginx:1.0
如果觉得docker run启动容器不方便,可以在/root/ruanjian/dockerfile/mynginx目录中vim docker-compose.yml,这样以后要启动容器只需要在这个目录中执行
docker-compose up -d即可将容器启动。
内容如下:
nginx:
image: nginx:1.0
restart: always
container_name: nginx
hostname: ‘nginx‘
ports:
- 80:80
volumes:
- ‘/opt/data/apps/nginx/conf:/usr/local/nginx/conf‘
dockerfile代码如下:
FROM centos:centos7.5.1804 MAINTAINER linuxtang<66907360@qq.com> RUN yum install -y epel-release && yum install -y vim wget gcc make pcre-devel zlib-devel openssl-devel libxm12-devel libxslt-devel luajit GeoIP-devel gd-devel libatomic_ops-devel luajit-devel perl-devel perl-ExtUtils-Embed RUN cd /tmp && wget https://openresty.org/download/openresty-1.19.3.1.tar.gz && tar zxmf openresty-1.19.3.1.tar.gz && cd openresty-1.19.3.1 && ./configure --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-libatomic --with-pcre-jit --with-stream_ssl_preread_module && gmake && gmake install ENV PATH $PATH:/usr/local/nginx/sbin RUN ln -s /usr/local/openresty/nginx /usr/local/nginx RUN ln -sf /dev/stdout /usr/local/nginx/logs/access.log && ln -sf /dev/stderr /usr/local/nginx/logs/error.log EXPOSE 80 ENTRYPOINT ["nginx","-g","daemon off;"]
docker和docker compose的安装方法:
docker compose是单机多容器部署工具
#安装yum工具
yum install -y yum-utils
#安装docker官方yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#安装docker及docker copose应用
yum install -y docker-ce docker-compose
#设置docker服务开机自启动
systemctl enable docker
#启动docker服务
systemctl start docker
#查看版本:
docker --version
docker-compose -v
备注:如果docker-compose安装失败,请从https://github.com/docker/compose/releases/tag/1.25.0-rc4直接下载需要的版本到/usr/local/bin目录下,并重命名为
docker-compose,然后执行chmod +x /usr/local/bin/docker-compose,最后
docker-compose -v验证是否安装成功
标签:image 下载 nss entry data 高并发 str 开机自启 ln -s
原文地址:https://www.cnblogs.com/tyjs09/p/14286000.html