In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces "CentOS7 Docker Nginx deployment and operation case analysis" in detail, with detailed content, clear steps and proper handling of details. I hope this "CentOS7 Docker Nginx deployment and operation case analysis" article can help you solve your doubts.
1. Resource preparation
Dockerfile file
# "ported" by adam miller from # https://github.com/fedora-cloud/fedora-dockerfiles originally written for fedora-dockerfiles by # scollier from centos:centos7 maintainer the centos project run yum-y update; yum clean all run yum-y install epel-release tar; yum clean all run yum-y install nginx; yum clean all add nginx.conf / opt/deploy/nginx/nginx.conf run echo "daemon off "> > / opt/deploy/nginx/nginx.conf # run curl https://git.centos.org/sources/httpd/c7/acf5cccf4afaecf3afeb18c50ae59fd5c6504910\ # | tar-xz-c / usr/local/nginx/html\ #-- strip-components=1 # run sed-I-e's G'- e'/ apache_pb.gif/d'\ # / usr/local/nginx/html/index.html expose 80 # cmd [" / usr/local/nginx/sbin "]
Note: the path needs to exist on the system and correspond to
Nginx.conf file
# for more information on configuration, see: # * official english documentation: http://nginx.org/en/docs/ # * official russian documentation: http://nginx.org/ru/docs/ user nginx; worker_processes 1; error_log / usr/logs/nginx/error.log; # error_log / var/log/nginx/error.log notice; # error_log / var/log/nginx/error.log info; pid / run/nginx.pid; events {worker_connections 1024 } http {include mime.types; default_type application/octet-stream; log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / usr/logs/nginx/access.log main; sendfile on; # tcp_nopush on # keepalive_timeout 0; keepalive_timeout 65; # gzip on; # load modular configuration files from the / etc/nginx/conf.d directory. # see http://nginx.org/en/docs/ngx_core_module.html#include # for more information. # include / etc/nginx/conf.d/*.conf; index index.html index.htm; server {listen 80; server_name localhost; root / usr/share/nginx/html; # charset koi8-r; # access_log / var/log/nginx/host.access.log main; location / {autoindex on } # redirect server error pages to the static page / 40x.html # error_page 404 / 404.html; location = / 40x.html {} # redirect server error pages to the static page / 50x.html # error_page 500 502 503 504 / 50x.html Location = / 50x.html {} # proxy the php scripts to apache listening on 127.0.0.1 location 80 # location ~. Php$ {# proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1 proxy the php scripts to apache listening on 9000 # # location ~. Php$ {# root html # fastcgi_pass 127.0.0.1 include fastcgi_params; 9000; # fastcgi_index index.php; # fastcgi_param script_filename / scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if apache's document root # concurs with nginx's one # # location ~ /\ .ht {# deny all #}} # another virtual host using mix of ip-, name-, and port-based configuration # # server {# listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # location / {#} #} # https server # # server {# listen 443; # server_name localhost; # root html # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols sslv2 sslv3 tlsv1; # ssl_ciphers highlyFleur Md5; # ssl_prefer_server_ciphers on; # location / {#} #}}
Note: the path needs to exist on the system and correspond to
2. Execute the command to build an image
The copy code is as follows:
[root@localhost nginx] # sudo docker build-rm-tag os7/nginx:centos7.
Screenshot of the execution result:
3. Check whether the image installs and builds docker images successfully.
4. Create the container docker run-I-t-d-p 192.168.32.129Vera 81 os7/nginx / bin/bash
Note: the ip of 192.168.32.129 needs to be added to / etc/hosts
192.168.32.129 localhost
5. Check whether the container has been created successfully and start docker ps
6. Test whether you have successfully accessed curl http://192.168.32.129:81
This denied connection will occur, so what should I do? There is a solution. Let's go into the container first.
7. Enter the container docker exec-I-t small_hodgkin / bin/sh
8. Then execute it in the container (just enter it directly)
Nginx
9. Execute curl http://192.168.32.129:81 outside the container
Succeed.
10. Access it through the browser outside the virtual machine
After reading this, the article "CentOS7 Docker Nginx deployment and Operation example Analysis" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it. If you want to know more about related articles, you are 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.