Serve static file

tseveendorj tseveendorj at gmail.com
Fri Jan 14 07:19:43 MSK 2011


Hello,

I thought I've configured Nginx serve static content itself. How do I 
know Nginx is serving Static content on itself.

my config

server {

# Replace this port with the right one for your requirements
   listen       80;  #could also be 1.2.3.4:80

   # Multiple hostnames separated by spaces.  Replace these as well.
   server_name  example.com; #Alternately: _

   root /var/www/example;

         error_page  400 /apache_errors/index400.html;
         error_page  401 /apache_errors/index401.html;
         error_page  403 /apache_errors/index403.html;
         error_page  404 /apache_errors/index404.html;
         error_page  500 /apache_errors/index500.html;


   client_max_body_size 15M;

   access_log  /var/log/nginx/example.access.log;
   error_log /var/log/nginx/example.error.log error;
   index  index.html index.php;

   # serve static files directly
   location ~* 
^.+\.(jpg|jpeg|gif|css|png|js|ico|html|mp3|mp4|avi|swf|flv)$ {
     access_log        off;
     expires           30d;
   }

  location ~ .php$ {
         include fastcgi_params;
         fastcgi_split_path_info ^(.+\.php)(.*)$;
         #fastcgi_pass   127.0.0.1:9000;
         fastcgi_pass   unix:/var/run/php5-fpm.sock;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         fastcgi_intercept_errors        on;
         fastcgi_ignore_client_abort     off;
         fastcgi_connect_timeout 60;
         fastcgi_send_timeout 180;
         fastcgi_read_timeout 180;
         fastcgi_buffer_size 128k;
         fastcgi_buffers 4 256k;
         fastcgi_busy_buffers_size 256k;
         fastcgi_temp_file_write_size 256k;
     }
}


If the configuration is wrong please correct me.

Sincerely
Eberx



More information about the nginx mailing list