Nginx單機部署

   1、nginx單機部署(參考:https://www.runoob.com/linux/nginx-install-setup.html):

安裝到如下圖所示,不要採用菜鳥nginx的配置,另外在安裝前請先關閉防火牆

2、nginx配置

 2-1、nginx 配置如下。

 

user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;


    access_log on;
    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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            access_log  logs/start.log  main;
        }


        location /static {
            alias  /web/;
            #index  1.html ;
            expires 1d;
           access_log  logs/static.log  main;

關於access_log文件,必須在指定目錄下創建權限爲777文件,否則有機率產生nginx403問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章