【问题标题】:NGINX MAGENTO v1.7 CSS + JS Not WorkingNGINX MAGENTO v1.7 CSS + JS 不工作
【发布时间】:2013-11-21 17:21:34
【问题描述】:

我认为 NGINX 没有从我的根目录 */data/www/public_html/hotnstylish/public/* 的正确位置提供 magento CSS 和 JS 文件,但 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/"

我的虚拟主机配置文件如下(乱七八糟):

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/*;

}

【问题讨论】:

    标签: magento nginx centos php


    【解决方案1】:

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

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

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

    【讨论】:

    • 试过了,但还是一样。谢谢
    猜你喜欢
    • 2021-08-19
    • 2015-06-15
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 2023-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多