宝塔 -- Ngix下运行Magento 1.9x

最近在折腾一个magento项目,使用了宝塔,感觉挺方便。项目之前使用的apache作为http服务器,运行确实有点慢,手贱换成了Ngix,然而问题就出现了。网站index可以打开,但是二级页面却全部404了,分析原因主要是因为网站开启了伪静态。贴出Ngix配置代码,有同等病症的童鞋自取:

#START-SITE
server {
	listen 80;
	server_name  www.prasadini.com;
	access_log  logs/www.prasadini.com.access.log;
	root   D:/wwwroot/Magento-EE-Advanced;
	index  index.php default.php index.html index.htm default.html default.htm;
	
	include rewrite/www.prasadini.com.conf;
		
	#START-ERROR-PAGE
	error_page 403 /403.html;
	## error_page 404 /404.html;
    error_page 502 /502.html;
	#END-ERROR-PAGE
	
	#301-START
	#301-END
	
	
	#REFERER-START
	#REFERER-END
	
	#PROXY-START
	#PROXY-END
	
	#START-SSL
	#END-SSL
	## SSL CONFIGURATION
      #ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem; 
      #ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    
    location = /js/index.php/x.js {
    	rewrite ^(.*\.php)/ $1 last;
    }

    ## Main Magento @location
    location / {
   		try_files $uri $uri/ @rewrite;
    }
    location /. {
	    return 404;
	}

	## These locations are protected
    location ~ /(app|var|downloader|includes|pkginfo)/ {
   		deny all;
    }
    ## Images
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
       expires max;
       log_not_found off;
       access_log off;
       add_header ETag "";
    }
       
    ## Fonts
	location ~* \.(swf|eot|ttf|otf|woff|woff2)$ {
		expires max;
		log_not_found off;
        access_log off;
		add_header ETag "";
		add_header Access-Control-Allow-Origin "example.com, cdn.example.com";
		add_header Cache-Control "public";
	}	
	location = /favicon.ico {
       log_not_found off;
       access_log off;
    }
    location = /robots.txt {
       allow all;
       log_not_found off;
       access_log off;
    }
	#START-PHP
	location @rewrite {
       rewrite / /index.php;
    }

	location ~ \.php$ {
		root   D:/wwwroot/Magento-EE-Advanced;
		fastcgi_pass   127.0.0.1:4556;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;

		try_files $uri =404;
		#fastcgi_param MAGE_RUN_CODE $mage_code;
        #fastcgi_param MAGE_RUN_TYPE $mage_type;
        fastcgi_keep_conn       on;

    }
	#END-PHP
}
#END-SITE

修改完成后重启Ngix,刷新,一切正常,运行如飞。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值