NGINX MAGENTO v1.7 CSS + JS无效

时间:2013-11-21 00:08:20

标签: magento nginx centos php

我认为NGINX不提供magento CSS&来自正确位置的JS文件我的根是* / data / www / public_html / hotnstylish / public / *但是nginx似乎认为它的/ etc / nginx / html!前端和后端都没有任何风格加载任何线索都会很棒!

我的NGINX错误日志的一部分:

2013/11/20 23:26:08 [error] 13982#0: *3 open() "/etc/nginx/html/js/calendar/calendar.js" failed (2: No such file or directory), client: 89.168.219.134, server: 836237.vps-10.com, request: "GET /js/calendar/calendar.js HTTP/1.1", host: "836237.vps-10.com", referrer: "http://836237.vps-10.com/index.php/admin/dashboard/index/key/d6a8576bd8743279b6812c60ccd6b464/"

2013/11/20 23:26:08 [error] 13982#0: *5 open() "/etc/nginx/html/js/calendar/calendar-setup.js" failed (2: No such file or directory), client: 89.168.219.134, server: 836237.vps-10.com, request: "GET /js/calendar/calendar-setup.js HTTP/1.1", host: "836237.vps-10.com", referrer: "http://836237.vps-10.com/index.php/admin/dashboard/index/key/d6a8576bd8743279b6812c60ccd6b464/"

我的vhost配置文件如下(乱糟糟的地狱):

server {
listen       80;
server_name  836237.vps-10.com;
root   /data/www/public_html/hotnstylish/public/;

access_log  /data/www/public_html/hotnstylish/log/access.log;
error_log /data/www/public_html/hotnstylish/log/error.log;

location / {
    root   /data/www/public_html/hotnstylish/public/;
    index  index.html index.htm index.php;
    try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
    expires 30d; ## Assume all files are cachable
    include /etc/nginx/mime.types;
}

# error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
# location ~ \.php$ {
# proxy_pass   http://127.0.0.1;
#}

## These locations would be hidden by .htaccess normally
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 ^~ /var/                { deny all; }


 location ~ \.css {
    add_header  Content-Type    text/css;
}
location ~ \.js {
    add_header  Content-Type    application/x-javascript;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
  location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
  location /var/export/ { internal; }
  location /. { return 404; }
  location @handler { rewrite / /index.php; }
  location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
  location ~* .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
root           /data/www/public_html/hotnstylish/public/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;


# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}
}
}

我的Ngingx.conf:

user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
worker_connections  1024;
}

http {
#include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request "'
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
access_log  /var/log/nginx/access.log  main;

sendfile        on;
autoindex off;
map $scheme $fastcgi_https { ## Detect when HTTPS is used
    default off;
    https on;
}

keepalive_timeout  10;

gzip  on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types      text/plain text/html text/css application/x-javascript text/xml       application/xml application/xml+rss text/javascript;

# Load config files from the /etc/nginx/conf.d directory
#include /etc/nginx/conf.d/*.conf;

#Load vHosts file for each site separately
include /etc/nginx/sites-enabled/*;

}

1 个答案:

答案 0 :(得分:0)

确保在正确的server_name上下文中处理您的请求。

如果您使用nginx≥0.8.21尝试设置

listen       80 default_server;
server_name  836237.vps-10.com;