nginx 配置文件备份 nginx.conf and vhosts

bogon:vhosts xingchong$ brew services restart nginx

Stopping `nginx`... (might take a while)

==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)

==> Successfully started `nginx` (label: homebrew.mxcl.nginx)

bogon:vhosts xingchong$ cat sfire.com.conf 

server {

    listen       9090;

    server_name  sfire.com;

    root         /Users/xingchong/Documents/code/php/super_fire/htdocs;

    # Load configuration files for the default server block.

 

    location / {

        index  index.php index.html index.htm;

    autoindex on;  

    autoindex_exact_size on;  

    autoindex_localtime on;  

    }

    location ~* \.php$ {

 

        fastcgi_index   index.php;

        fastcgi_pass    127.0.0.1:9000;

        include         fastcgi_params;

        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;

        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

    }

    error_page 404 /404.html;

        location = /40x.html {

    }

    error_page 500 502 503 504 /50x.html;

        location = /50x.html {

    }

}

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ pwd

/usr/local/etc/nginx/vhosts

bogon:vhosts xingchong$ 

 

 

 

 

 

 

 

 

    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;

 

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

 

    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;

 

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

    include servers/*;

 

    #the vhosts config

    include /usr/local/etc/nginx/vhosts/*.conf;

}

 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

bogon:vhosts xingchong$ 

 

 

 

 

linux centos 安装nginx

 

yum install -y nginx

 

基本配置文件 vim /etc/nginx/nginx.conf

 

解决目录访问问题:

user root;

 

autoindex on;

autoindex_exact_size on;

autoindex_localtime on;

 

目标目录的权限要足够  chmod -R 777 www

 

引入配置文件方法:

 

include servers/*.conf;

}

 

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
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 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    autoindex on;
    autoindex_exact_size on;
    autoindex_localtime on;

    # 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       90;
        listen       [::]:90;
        server_name  _;
        root         /usr/share/nginx/html;

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

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

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        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;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

include servers/*.conf;
}

 

posted @ 2018-01-31 12:22  会飞的斧头  阅读(355)  评论(0编辑  收藏  举报