In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to build the Nginx environment in Docker, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Docker's Nginx environment building Nginx installation tutorial
Linux environment
Install in Linux
Install compilation tools and library files
Yum-y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
First install PCRE
The function of PCRE is to make Nginx support Rewrite function.
Install if prompted without wget (it is not installed by default in the source centos pulled by Docker)
Yum-y install wget
Enter the program installation directory
Cd / usr/local/src/
Download the pcre installation package
Wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
Extract the installation package:
Tar-zxvf pcre-8.35.tar.gz
Delete installation package
Rm-rf pcre-8.35.tar.gz
Enter the installation package
Cd pcre-8.35
Compilation and installation
. / configuremake & & make install
View pcre version
Preconv-- version [root@de790c02f7b6 pcre-8.35] # preconv-- versionGNU preconv (groff) version 1.22.2 with iconv support
Install Nginx
Download the installation package
Wget http://nginx.org/download/nginx-1.6.2.tar.gz
Installation
Cd nginx-1.8.0. / configure-- prefix=/usr/local/nginx make make install
Check the installation result
/ usr/local/nginx/sbin/nginx-vDockerfile installation
Script
FROM centos:latest## producer Information MAINTAINER xiachaoyang xiazhaoyang@live.comRUN yum install-y pcre-devel wget net-tools gcc zlib zlib-devel make openssl-devel## create directory RUN mkdir-p / usr/local/nginx## Local installation directly automatically decompress # # ADD nginx-1.8.0.tar.gz / usr/local/src## online installation RUN cd / usr/local/srcADD http://nginx.org/download/nginx-1.8 .0.tar.gz .Run tar-zxvf nginx-1.8.0.tar.gzRUN ln-s / usr/local/src / componetsRUN cd nginx-1.8.0 & &. / configure-- prefix=/usr/local/nginx & & make & & make installRUN rm-vf / usr/local/nginx/conf/nginx.confADD http://www.apelearn.com/study_v2/.nginx_conf / usr/local/nginx/conf/nginx.confEXPOSE 8commands set up to execute commands at startup # ENTRYPOINT / usr/local/nginx/sbin/nginx-v
Mirror image
Docker build-t env-nginx.
Docker images
Docker tag [mirror ID] env-nginx:1.0
Docker run-I-t-p 80:80 env-nginx:1.0
Clear Nginx Docker
Docker rm-f docker container ls-a-Q
Docker rmi-f env-nginx:2.0
Docker build-t env-nginx:2.0.
Docker run-I-t-p 8001Rank 80-name nginx-restart=always env-nginx:2.0
Execute nginx after running
XiazhaoyangdeMacBook-Pro:~ xiazhaoyang$ docker run-I-t-p 8001root@56dfba762876 80-- restart=always 127.0.0.1:5000/env-nginx:1.0 [root@56dfba762876 /] # cd usr/local/nginx/sbin/ [root@56dfba762876 sbin] # lsnginx [root@56dfba762876 sbin] #. / nginx-v nginx version: nginx/1.8.0 [root@56dfba762876 sbin] # ps-ef | grep nginxroot 18 10 07:44 pts/0 00:00:00 grep-- color=auto Nginx [root@56dfba762876 sbin] #. / nginx [root@56dfba762876 sbin] # ps-ef | grep nginxroot 20 10 07:45? 00:00:00 nginx: master process. / nginxnobody 21 200 07:45? 00:00:00 nginx: worker processnobody 22 200 07:45? 00:00:00 nginx: worker process
Configure routin
Close nginx
. / nginx-s stop
XiazhaoyangdeMacBook-Pro:~ xiazhaoyang$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES56dfba762876 127.0.0.1:5000/env-nginx:1.0 "/ bin/bash" 10 minutes ago Up 10 minutes 0.0.0.0 minutes ago Up 8001-> 80/tcp brave _ kowalevskid75f05b4d7f8 hyper/docker-registry-web "start.sh" 5 days ago Up About an hour 0.0.0.0 days ago Up About an hour 8000-> 8080/tcp local-docker-res-web1b5239bc943b registry "/ entrypoint.sh / etc …" 5 days ago Up About an hour 0.0.0.0 lsnginx 5000-> 5000/tcp local-docker-resxiazhaoyangdeMacBook-Pro:~ xiazhaoyang$ docker attach 56dfba762876 [root@56dfba762876 sbin] # lsnginx [root@56dfba762876 sbin] # cd. [root@56dfba762876 nginx] # lsclient_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_ temp [root @ 56dfba762876 nginx] # cd cclient_body_temp/ conf/ [root@56dfba762876 nginx] # cd conf/ [root @ 56dfba762876 conf] # lsfastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utffastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_ params.default [root @ 56dfba762876 conf] # cd.. / sbin/ [root@56dfba762876 sbin] #. / nginx-s stop [ Root@56dfba762876 sbin] # ps-ef | grep nginxroot 30 1 0 07:55 pts/0 00:00:00 grep-- color=auto nginx
Modify routing configuration
Vi nginx.config
[root@56dfba762876 conf] # cd.. / sbin/ [root@56dfba762876 sbin] #. / nginx [root@56dfba762876 sbin] # cd.. [root@56dfba762876 nginx] # cd conf/ [root@56dfba762876 conf] # vi nginx.conf [root@56dfba762876 conf] # cd.. / sbin/ [root@56dfba762876 sbin] #. / nginx-s stop [root@56dfba762876 sbin] #. / nginx [root@56dfba762876 sbin] # server {listen 80; server_name localhost; index index.html index.htm index.php Root / usr/local/nginx/html; location ~\ .php$ {include fastcgi_params; fastcgi_pass unix:/tmp/php-fcgi.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / usr/local/nginx/html$fastcgi_script_name;} location / docker-registry-web/ {proxy_pass http://192.168.2.102:8000/; Proxy_redirect default;} location / jenkins/ {proxy_pass http://192.168.2.102:8002/; proxy_redirect default;}}
Jenkins mapping effect via nginx
These are all the contents of the article "how to build a Nginx environment in Docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.