无法在opencart nginx中输入admin部分

时间:2014-04-16 11:20:06

标签: nginx opencart

我已经通过Opencart网站从Apache转移到Nginx.In Apache一切正常,在Nginx中我无法进入管理部分尽管密码正确,并且每次后续尝试都会继续显示登录页面。除此之外addtocart按钮没有反应。配置文件似乎没问题。我尝试了不同的选项,到目前为止没有任何帮助。任何帮助将不胜感激。 感谢。

   server {
          listen 80;
          server_name opencart.local;
  return 301 $scheme://www.opencart.local$request_uri;
}

server {
listen 80; # listen for ipv4; this line is default and implied
server_name www.opencart.local;
root /home/arch/mysites/opencart;
index index.php index.html index.htm;
charset UTF-8;
#autoindex off;

access_log /var/log/nginx/opencart.local.access.log;
error_log /var/log/nginx/opencart.local.error.log;
# Add trailing slash to */admin requests.
rewrite /admin$ $scheme://$host$uri/ permanent;

 location /image/data {
    autoindex on;
  }
location /admin {
    index index.php;
}
location / {
    try_files $uri @opencart;
}
location @opencart {
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location = /favicon.ico {
    log_not_found off;
    access_log off;
}
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
# Make sure files with the following extensions do not get loaded by nginx 
location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}
location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
    expires max;
    log_not_found off;
}
location ~ \.php$ {
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}


}

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。实际上我的/ etc / hosts文件中有几个名为opencart.local的虚拟主机,如下所示。

 127.0.0.1 opencart.local opencart
 127.0.0.1 opencart1.local opencart1 

在我的配置文件中,我删除了第一个服务器部分:

 server {
      listen 80;
      server_name opencart.local;
 return 301 $scheme://www.opencart.local$request_uri;
}

在下一节我写道:

   server {
   listen 80; # listen for ipv4; this line is default and implied
   server_name  opencart.local www.opencart.local;  <---
   root /home/arch/mysites/opencart;
    index index.php index.html

这可能是/ etc / hosts文件中指定主机名的结果。现在我可以进入admin部分,addtocart按钮也可以。