NGINX Configuration How To

Those of you who are in need of configuration for NGINX assuming you have everything installed - I am still working on SSL configuration which I will post here shortly in your conf.d directory create a file called http.conf and paste this *** DONT FORGET TO MODIFY THE FILE WITH YOUR DOMAIN AND DIRECTORY



server {
listen 80;
server_name www.YOURDOMAIN.com YOURDOMAIN.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /var/www/YOURDOMAIN/public_html;
index index.php;
try_files $uri $uri/ /index.php?sef_rewrite=1;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/YOURDOMAIN/public_html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/YOURDOMAIN/public_html$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

location ~* \.(css|js|jpg|jpeg|png|swf|gif|svg|ttf|eot)$ {
root /var/www/YOURDOMAIN/public_html;
try_files $uri http://backend$1;
access_log /var/log/nginx/static.access.log;
error_log /var/log/nginx/.static.error.log;
expires 60d;
add_header Cache-Control "public";
add_header Last-Modified "Sat, 30 Mar 2013 21:47:15 GMT";
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#

location ~ /\.ht {
deny all;
}
}

Where to config these files ?

This is a vhost file example.



And Nginx SSL configuration is easy:





server {
listen 443 ssl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/cert.key;
}

http://backend$1 ?