nginx用起来真是又爱又恨

2020-11-11  本文已影响0人  美雨知春

今天在docker上配置了一下多个域名,当然多个域名都指向80端口啊,可是原来都是好好的,怎在dockers上就是不行呢,前两天刚刚因为配置cgi受了伤,这次隐隐感到是不是同一个伤口又被提起呢,其实不是,是少复制了两句话,只凭自己的记忆配置了一下,发现自己还是内功不足啊。下面摆上我的配置成功的配置文件
nginx.conf 基本的配置文件
nginx.d/gateway.xxx.cn 域名的配置文件

前提是

yum install nginx
yum install php-fpm

把php-fpm启动起来

  1. nginx.conf
user gateway;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include /etc/nginx/conf.d/*.conf;
    # 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.
    server {
        listen       80;
    #    listen       [::]:80 default_server;
        server_name _;
      root         /app/html/;

        include /etc/nginx/default.d/*.conf;   //这句话丢了不行,配置失败原因之一
        # Load configuration files for the default server block.
       
    location / {
    }

       location ~ \.php$ {
             root         /app/html/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME   /app/html$fastcgi_script_name;
             include        fastcgi_params;  //这句话丢了不行,配置失败原因之一
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

}
  1. nginx.d/gateway.xxx.cn
server {
        listen       80;
    #    listen       [::]:80 default_server;
        server_name gateway.xxx.cn inno.gateway.xxx.cn ;
 root         /app/interface;
        # Load configuration files for the default server block.
  include /etc/nginx/default.d/*.conf;     
    location / {
        index  index.php;
    }

       location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /app/interface$fastcgi_script_name;
             include         /etc/nginx/fastcgi_params; //这句话丢了不行,配置失败原因之一
        } 
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读