首页加载无样式

安装报错 · tju070 · 于 6年前 发布 · 2750 次阅读

场景描述:

配置完系统后打开首页
http://appfront.fecshoptest.com
以上地址都在/etc/hosts里有相关设定
通过Chrome的Developer Tools监控发现,请求以下地址出错( 404 Not Found)
http://appfront.fecshoptest.com:8080/customer/ajax?currentUrl=http%3A%2F%2Fappfront.fecshoptest.com%3A8080%2F&product_id=
整个页面无样式
共收到 16 条回复 fecshop
Fecmall#16年前 0 个赞

您是通过vagrant安装的,还是完全自己部署的环境?

把您的服务器环境发一下,操作系统,php mysql版本。

无样式的具体显示,截图发上来看一下。到底是什么样子。

tju070#26年前 0 个赞

补充:

CSS, JS, PNG文件正常加载 
tju070#36年前 0 个赞

自己部署的,手动版

tju070#46年前 0 个赞

发群里了

tju070#56年前 0 个赞

OS: MacOS 10.12.5 PHP: 5.6.30 MySQL: 5.7.18 MongoDB: 3.4.4 php extension: mongo, mongodb

xi_qing#66年前 0 个赞

为什么404的这个地址上会带有8080端口,是否与这个有关,试试看

tju070#76年前 0 个赞

我Nginx的端口没有用80, 用的是8080,若改成80也是出错,出错信息表示customer/ajax这个请求找不到,将customer/ajax改成customer/ajax123, customer/ajax456也是一样的效果,跟参数无关

tju070#86年前 0 个赞

应该是下面一段码执行的时候出了问题

loginInfoUrl = currentBaseUrl+"/customer/ajax";
	logoutUrl 	 = $(".logoutUrl").val();
	product_id   = $(".product_view_id").val();
	product_id	 = product_id ? product_id : null;
	jQuery.ajax({
		async:true,
		timeout: 6000,
		dataType: 'json', 
		type:'get',
		data: {
			'currentUrl':window.location.href,
			'product_id':product_id
		},
		url:loginInfoUrl,
		success:function(data, textStatus){ 
			welcome = $('.welcome_str').val();
			logoutStr = $('.logoutStr').val();
			if(data.loginStatus){
				customer_name = data.customer_name;
				str = '<span id="welcome">'+welcome+' '+customer_name+',</span>';
				str += '<span id="js_isNotLogin">';
				str += '<a href="'+logoutUrl+'" rel="nofollow">'+logoutStr+'</a>';
				str += '</span>';
				$(".login-text").html(str);
			}
			if(data.favorite){
				$(".myFavorite_nohove").addClass("act");
				$(".myFavorite_nohove a").addClass("act");
			}
			if(data.favorite_product_count){
				$("#js_favour_num").html(data.favorite_product_count);
			}
			if(data.csrfName && data.csrfVal && data.product_id){
				$(".product_csrf").attr("name",data.csrfName);
				$(".product_csrf").val(data.csrfVal);
			}
			if(data.cart_qty){
				$("#js_cart_items").html(data.cart_qty);
			}
			
			
		},
		error:function (XMLHttpRequest, textStatus, errorThrown){}
	});
	
Fecmall#96年前 0 个赞

你说了一顿,和没说没有分别,没法回答你的问题,自己去解决吧

别人如果提供这些信息给你,问你问题,你根据这些信息,你能解决吗?扣心自问一下。

你从这几个角度去分析:

样式没有加载,你查看一下加载的css和js的链接,然后吧地址直接贴到浏览器中直接访问,是否可以访问到

如果访问不到,是不是自己nginx或者fecshop配置错了。导致css和js无法访问到。

自己是否已经把fecshop的配置完全的看完并严格执行?

tju070#106年前 0 个赞

谢谢你的代码,我试着自己解决,辛苦你了

Fecmall#116年前 0 个赞

@tju070 #10楼 报错的截图也没发上来,问题描述清楚了,才能猜测问题所在

tju070#126年前 0 个赞

问题找到了,是Nginx阻止了对于 /customer/ajax的访问,需要调整nginx的配置,你这里的nginx配置码是不是可以发出来,我当前的配置如下

  1 server {
  2     listen 80;
  3     server_name appfront.fecshoptest.com appfront.fecshoptest.es;
  4     #server_name appfront.fecshoptest.com appfront.fecshoptest.es;
  5     index index.html index.php;
  6     location ~ .*\.(php) $
  7     {
  8         root /Users/tju/Workspace/xry/fecshop/appfront/web;
  9         fastcgi_pass 127.0.0.1:9000;    #php-fpm的默认端口是9000
 10         fastcgi_index index.php;
 11         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 12         include fastcgi_params;
 13     }
 14 }
Fecmall#136年前 0 个赞

可以,配置如下:(我是ssl配置的,如果是http的方式,请使用80端口,并去掉ssl的相关配置)


server {
#  listen     80  ;
	listen 443 ssl http2;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/fecshop.appfront.fancyecommerce.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/fecshop.appfront.fancyecommerce.com/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
		
    server_name fecshop.appadmin.fancyecommerce.com;
    root  /www/web/develop/fecshop/appadmin/web;
    server_tokens off;
    include none.conf;
    index index.php index.html index.htm;
    access_log /www/web_logs/access.log wwwlogs;
    error_log  /www/web_logs/error.log  notice;
	location /en/ {
		index index.php;
		if (!-e $request_filename){
			rewrite . /en/index.php last;
		}
    }

    location ~ \.php$ {
                        fastcgi_pass   127.0.0.1:9000;
                        fastcgi_index  index.php;
                        include fcgi.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                expires      30d;
        }

        location ~ .*\.(js|css)?$ {
                expires      12h;
        }
        location /api {
                rewrite /api/([a-z][0-9a-z_]+)/?$ /api.php?type=$1;
        }


}



server {
           listen       80;
           server_name  fecshop.appadmin.fancyecommerce.com fecshop.appfront.fancyecommerce.com fecshop.appfront.es.fancyecommerce.com;
           rewrite ^(.*)$ https://$host$1 permanent;    
          
}

server {
#   listen     80  ;
	listen 443 ssl http2;
    ssl on;
    ssl_certificate /etc/letsencrypt/live/fecshop.appfront.fancyecommerce.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/fecshop.appfront.fancyecommerce.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   
    server_name fecshop.appfront.fancyecommerce.com fecshop.appfront.es.fancyecommerce.com;
    root  /www/web/develop/fecshop/appfront/web;
	server_tokens off;
    include none.conf;
    index index.php index.html index.htm;
    access_log /www/web_logs/access.log wwwlogs;
    error_log  /www/web_logs/error.log  notice;
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include fcgi.conf;
    }

	location ~ /sitemap.xml 
	{   
		if ($host  ~ .*appfront.es.fancyecommerce.com) {  
			rewrite ^/sitemap\.xml /sitemap_es.xml last;  
		}
	}

	location /fr/ {
        index index.php;
        if (!-e $request_filename){
                rewrite . /fr/index.php last;
        }
	}
	location /es/ {
        index index.php;
        if (!-e $request_filename){
                rewrite . /es/index.php last;
        }
	}

	location /cn/ {
        index index.php;
        if (!-e $request_filename){
                rewrite . /cn/index.php last;
        }
    }

	location /de/ {
        index index.php;
        if (!-e $request_filename){
                rewrite . /de/index.php last;
        }
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
            expires      30d;
    }

    location ~ .*\.(js|css)?$ {
            expires      12h;
    }


}

none.conf 是一些安全屏蔽,不让其访问一些路径的配置:

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 30d; ## Assume all files are cachable
#		rewrite ^/$ /index.php last;
#        rewrite ^/(?!index\.php|robots\.txt|static)(.*)$ /index.php/$1 last;
    }

    ## 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 /var/email/ {allow all;}
    location /var/export/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
        autoindex            on;
    }
      location  /. { ## Disable .htaccess and other hidden files
        return 404;
    }

    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }

    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*.php)/ $1 last;
    }
tju070#146年前 0 个赞

首页正常了,但首页上所有的链接都失效(404 Not found)

Fecmall#156年前 0 个赞

你把none.conf 部分的配置加进去就可以了,需要rewrite

Fecmall#166年前 0 个赞

@tju070 #14楼 https://pan.baidu.com/s/1kVwRD2Z 百度云盘 里面有一个环境配置文件.rar /usr/local/nginx/conf里面是我的nginx,之前的一个例子。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics