Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker install nginx

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Find Mirror

Docker search nginx

two。 Pull the image

Docker pull nginx

3. Create a mount directory

Mkdir conf

Mkdir develop

Ls

4. Go to the conf directory and create a nginx.conf configuration file

# gzip Settings

Gzip on

Gzip_vary on

Gzip_comp_level 6

Gzip_buffers 16 8k

Gzip_min_length 1000

Gzip_proxied any

Gzip_disable "msie6"

# gzip_http_version 1.0

Gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript

Server {

Listen 80

Server_name localhost

# charset koi8-r

# access_log / var/log/nginx/host.access.log main

# location / {

# root / usr/share/nginx/html

# index index.html index.htm

The function of # is to check the existence of files in order, return the first found file or folder (ending with a slash as a folder), and if all files or folders cannot be found, an internal redirection is performed to the last parameter.

# try_files $uri / index.html

#}

Location / {

Root / usr/share/nginx/html

Index index.html index.htm

}

# error_page 404 / 404.html

# redirect server error pages to the static page / 50x.html

#

Error_page 500 502 503 504 / 50x.html

Location = / 50x.html {

Root / usr/share/nginx/html

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

# location ~\ .php$ {

# proxy_pass http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

# location ~\ .php$ {

# root html

# fastcgi_pass 127.0.0.1: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

#}

}

5. Start the container

Docker run-- name nginx-p 80:80-- privileged=true-v / usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/conf.d/default.conf-v / usr/local/docker/nginx/develop/dist/:/usr/share/nginx/html/-d nginx

6. View container status

7. test

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report