配置laravel的nginx站点

server{}配置

server{
        #端口配置
        listen 80;
        #域名配置
        server_name laravel.cc;

        index index.php index.html index.htm;
        #站点配置到public
        root /data/wwwroot/laravel.cc/public;
      #日志记录
        access_log /data/logs/nginx.laravel.cc.log access;
        error_log /data/logs/nginx.laravel.cc.error debug;
     #静态文件配置
        location ~ .*\.(jpg|jpeg|gif|png|bmp|css|js|swf|txt|ttf|woff|ico)$ {
                expires 7d;
                break;
        }

        location / {
         #重点区
                try_files \$uri \$uri/ /index.php?$query_string;
                index index.php index.html index.htm;
        }
        #静态文件配置
        location /logs {
                autoindex on;
                autoindex_exact_size off;
                autoindex_localtime on;
                break;
        }
        #处理php配置
        location ~ "\.php$" {
                include fastcgi_params;
                fastcgi_index index.php;
                #在nginx.conf配置server_mango
                fastcgi_pass server_mango;
        }
}

http下的server_mango配置
  

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"';

    log_format access '$remote_addr [$time_local] "$http_host" "$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;
    server_tokens       off;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip on;
    gzip_min_length  5k;
    gzip_buffers     4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types       text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    #重点区与server{}中的处理php应用到的
    upstream server_mango {
        server 127.0.0.1:9000;
    }
    #加载vhost下的.conf后缀所有文件
    include /usr/local/nginx/conf/vhost/*.conf;
}
标签:Nginx 发布于:2019-11-05 13:26:25