I am trying doing a magento installation on a server. Here is my Vhost file.
server {
listen 80;
## SSL directives might go here
server_name development.magento.in ; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/devcode/;
client_max_body_size 2M;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 365d; ## Assume all files are cachable
}
if ($request_uri = /index.php) {
rewrite ^ http://$host? permanent;
}
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /shell/ { deny all; }
location /downloader/ { deny all; }
location /cron.php { deny all; }
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
# serve static files directly
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|txt)$ {
# root /var/www/devcode/skin/; # I tried to added to this also but never worked
access_log off;
expires 30d;
}
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
}
So by this config Nginx shows 403 for Css and js and Images. The funny part is if I remove the section for serving static files it show 404. I have tried all the posts on Stackoverflow. Here is how my Media and skin directory permissions looks like
drwxr-xr-x. 23 nginx nginx 4096 Mar 22 14:32 media
drwxr-xr-x. 5 nginx nginx 4096 Mar 13 03:45 skin
Any help or hint will be highly respected!
EDIT
My New Conf File goes like that:
server {
listen 80;
## SSL directives might go here
server_name development.magento.in ; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/devcode/;
index index.html index.php; ## Allow a static html file to be shown first
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
access_log /var/log/nginx/development.access.log ;
error_log /var/log/nginx/development.error.log ;
client_max_body_size 2M;
location / {
try_files $uri $uri/ /index.php?$args; #@handler; ## If missing pass the URI to Magento's front handler
expires 365d; ## Assume all files are cachable
}
if ($request_uri = /index.php) {
rewrite ^ http://$host? permanent;
}
location ^~ /(app|includes|lib|media/downloadable|pkginfo|var)/ { internal; }
location /var/export/ { internal; }
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
# serve static files directly
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|txt)$ {
access_log off;
expires 30d;
}
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_read_timeout 300;
}
}
Now My previous issue is Fixed. But now I can't get My site running. I have checked access.log it says HTTP 200 OK but index.php is not receiving any Request.