nginx基础配置说明一则

2019-10-17 21:14:39王冬梅

        index index.html index.htm index.php; #默认访问的首页 
    root  /usr/local/web/www/; #文件目录 
    error_page 404 403  http://admin.test.com/404.htm; #默认404页面 
        location ~ .*.(php|php5)?$   #php cgi模块 
        { 
          #fastcgi_pass  unix:/tmp/php-cgi.sock; 
          fastcgi_pass  127.0.0.1:9000; 
          fastcgi_index index.php; 
          include fcgi.conf; 
        } 
    location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ 
    { 
          expires      30d; 
        } 
       location /       #URL重写模块 
        { 
          index index.php; 
          if (!-f $request_filename){ 
                  rewrite (.*) /admin.php; 
              } 
          try_files $uri $uri/ /index.html; 
        } 
        location ~ .*.(js|css)?$ 
        { 
          expires      1h; 
        } 
        #以下是log模块-记录nginx日志 
        log_format access  '$remote_addr - $remote_user [$time_local] "$request" ' 
                  '$status $body_bytes_sent "$http_referer" ' 
                  '"$http_user_agent" $http_x_forwarded_for'; 
        access_log /usr/local/web/nginx.0.8.15/logs/access.log  access; 
          } 
    }