Ask for help: docker starts nginx mime.types and fastcgi_params to report an error

< H1 > question: < / H1 >
  1. when docker starts nginx, mime.types reports an error
  2. include fastcgi_params also reported an error in site configuration
< H2 > 1. Mime.types error related < / H2 >

nginx container error log:

2018/09/25 13:27:27 [emerg] 1-sharp1: open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:14
nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:14

the nginx.conf file is as follows

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/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"";

    -sharp access_log  logs/access.log  main;

    sendfile        on;
    -sharptcp_nopush     on;
    -sharpkeepalive_timeout  0;
    keepalive_timeout  65;

    -sharpgzip  on;

    server {
        -sharp listen       8080;
        -sharp server_name  localhost;

        -sharpcharset koi8-r;

        -sharpaccess_log  logs/host.access.log  main;

        -sharp location / {
        -sharp     root   html;
        -sharp     index  index.html index.htm;
        -sharp }

        -sharperror_page  404              /404.html;

        -sharp redirect server error pages to the static page /50x.html
        -sharp
        -sharp error_page   500 502 503 504  /50x.html;
        -sharp location = /50x.html {
        -sharp     root   html;
        -sharp }

        -sharp proxy the PHP scripts to Apache listening on 127.0.0.1:80
        -sharp
        -sharplocation ~ \.php$ {
        -sharp    proxy_pass   http://127.0.0.1;
        -sharp}

        -sharp pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        -sharp
        -sharplocation ~ \.php$ {
        -sharp    root           html;
        -sharp    fastcgi_pass   127.0.0.1:9000;
        -sharp    fastcgi_index  index.php;
        -sharp    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        -sharp    include        fastcgi_params;
        -sharp}

        -sharp deny access to .htaccess files, if Apache"s document root
        -sharp concurs with nginx"s one
        -sharp
        -sharplocation ~ /\.ht {
        -sharp    deny  all;
        -sharp}
    }

    -sharp HTTPS server
    -sharp
    -sharpserver {
    -sharp    listen       443 ssl;
    -sharp    server_name  localhost;

    -sharp    ssl_certificate      cert.pem;
    -sharp    ssl_certificate_key  cert.key;

    -sharp    ssl_session_cache    shared:SSL:1m;
    -sharp    ssl_session_timeout  5m;

    -sharp    ssl_ciphers  HIGH:!aNULL:!MD5;
    -sharp    ssl_prefer_server_ciphers  on;

    -sharp    location / {
    -sharp        root   html;
    -sharp        index  index.html index.htm;
    -sharp    }
    -sharp}
    include ./conf.d/*;
}
< H2 > 2. Include fastcgi_params error related < / H2 >

nginx container error content

nginx: [emerg] open() "/etc/nginx/fastcgi_params" failed (2: No such file or directory) in /etc/nginx/./conf.d/www.php.cc.conf:23

www.php.cc.conf configuration

server {
    listen    80;
    server_name    www.php.cc;
    root    /etc/www/php;

    location / {
        index    index.html index.php index.htm;
    }
    -sharp
    error_page 404 /error.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
    -sharp pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_pass 172.17.0.3:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.ht {
        deny all;
    }
}
Jul.16,2021

check your mount configuration first. Sometimes some friends like to mount the entire nginx configuration directory to / etc/nginx. Do not realize that you only add nginx.conf to this directory, but there are many other files under the container / etc/nginx directory. If you mount the entire directory directly, other files will disappear as the directory is mounted, and there will be problems with the natural read configuration.

there are two ways to solve this problem:

  1. change directory mount to file mount, and mount only nginx.conf, that is,-v ~ / nginx/nginx.conf:/etc/nginx/nginx.conf
  2. is to copy other contents in the / etc/nginx directory in the container to the directory to be mounted, and mount them along with the directory

after reading the error report, it is obvious that the two files are not available under / etc/nginx . After entering the docker ssh, the path is output to see if the file exists at two o'clock and whether the permissions are correct


include mime.types; this file cannot be found. Do not dare to talk nonsense without seeing the configuration information when you turn on docker!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dd30-2bb3f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dd30-2bb3f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?