# Serve static file

**URL:** <https://www.ruby-forum.com/t/serve-static-file/201766>\
**Category:** NGINX\
**Created:** [January 14, 2011, 5:20am UTC](https://www.ruby-forum.com/t/serve-static-file/201766 "2011-01-14T05:20:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 14, 2011, 5:20am UTC](https://www.ruby-forum.com/t/serve-static-file/201766/1 "2011-01-14T05:20:59Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![tseveendorj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tseveendorj](https://www.ruby-forum.com/u/tseveendorj)\
**Post date:** [January 14, 2011, 6:43pm UTC](https://www.ruby-forum.com/t/serve-static-file/201766/2 "2011-01-14T18:43:50Z")

</div>

On 01/14/2011 01:19 AM, tseveendorj wrote:

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

- access\_log off;
- #access\_log off;

You told it not to log when you serve static content.

Also, you should change this:

- location ~ .php$ {

- location ~ .php$ {
