拉取镜像

创建目录

创建一个目录用来存放文件,方便我们进行修改

创建配置文件

在我们创建的目录下创建一个配置文件

修改配置文件

把我们创建的目录下的 nginx.conf 修改为以下内容

#工作进程数  1 ,不要超过计算机的核数,四核配置4,八核配置8
worker_processes  1;

#工作连接数,也就是线程,一个进程有1024个线程,
events {
    worker_connections  1024;
}

#http请求配置
http {
    default_type  application/octet-stream;

    #sendfile为发送文件,要on开启
    sendfile        on;

    #keepalive_timeout超时时间
    keepalive_timeout  65;

    server {
        #监听的端口,这里为80
        listen       80;
        #server_name就是域名,
        server_name  localhost;

        #location域名代理地址
        # / 代表所有请求路径
        location / {
            root /usr/share/nginx/html;
            index  index.html;
        }
    }
}

创建html

创建在 /everything/nginx/html目录下创建index.html

index.html内容为

<html>
<body>
<h1>我是index.html...</h1>
</body>
</html>

启动容器

访问

01-18 08:40
查看更多