centos 7インストールと配置nginx

5011 ワード

インストーラnginx:
sudo yum install nginx
 
設定nginx起動自動起動:
sudo systemtel enable inx
 
開始nginx:
sudo system start nginx
 
ファイアウォール80(HTTP)と443(HTTPS)ポートを開く:
sudo firewall-cmd--permant--zone=public--add-service=http
sudo firewall-cmd--permant--zone=public--add-service=https
sudo firewall-cmd--reload
 
上記のインストール方式によりインストールされたnginx後、配置ファイルはここにあります.

 
                                 
いくつかの良い実践の約束:/etc/nginx//etc/nginx/           conf.common.d/ name 1.com nf
                                                    name 2.conf                                                              web 1.com.1.8001.cnf
                                      web 2.comp.802.conf
1.ディレクトリの作成:           conf.d/    設定で重複して服用できる配置については、分類してこのディレクトリに置くことができます.必要な時はファイルに引用して変更管理しやすいです.
2.個別のnginx配置ごとにディレクトリに配置されています.  /etc/nginx/conf.common.d//etc/nginx/conf.d/3.設定ファイル以外に、ログ関連ファイルは  , web ( ) , " + .conf" /etc/nginx/conf.d/ に保存されています. 和  /var/log/nginx/ , access.logはアクセス権限とエラーログファイルにアクセスします.このようにエラーを検索すると、より便利になります.  error.log, web 1.com.8.001.log
centos7安装与配置nginx_第1张图片
 
4.配置するコードファイルは、以下のディレクトリ構造に従って保存することができます./var/log/nginx//usr/share/          nginx/               html//var/www/ web 1.com.801             / web.comp.802              
  /4.1 80 nginx html /usr/share/nginx/htmlは、展開するコードファイル4.2 を提供する.
 
 
 nginx主構成ファイル: /var/www/ + /   ( )参考:以下はnginx初期インストール時の設定の元のファイル内容viです.  /etc/nginx/nginx.conf
# 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 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;

    # 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;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}