简体   繁体   English

NGINX MAGENTO v1.7 CSS + JS不起作用

[英]NGINX MAGENTO v1.7 CSS + JS Not Working

I think NGINX isn't serving magento CSS & JS files from the correct location my root is */data/www/public_html/hotnstylish/public/* but nginx seems to think its /etc/nginx/html !?? 我认为NGINX不能从正确的位置提供magento CSS和JS文件,我的根目录是* / data / www / public_html / hotnstylish / public / *,但nginx似乎认为其/ etc / nginx / html! the frontend and backend both load with no style at all any clues would be great! 前端和后端都不会加载任何线索,这将是很棒的!

Part of my NGINX Error Log: 我的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/"

My vhost config file is as follows (messy as hell): 我的虚拟主机配置文件如下(乱七八糟):

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;
#}
}
}

My Ngingx.conf: 我的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/*;

}

Make sure that your request processed in right server_name context. 确保在正确的server_name上下文中处理您的请求。

If you use nginx ≥0.8.21 try to set 如果您使用nginx≥0.8.21,请尝试设置

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM